Skip to main content

Authentication

Every request to the Medipim API must be authenticated using Basic authentication. Use your API key ID as the username and your API key secret as the password. If you don't have credentials yet, contact info@medipim.com.

Try it in the browser

Each endpoint in the API Reference has an interactive request panel with an Auth section where you can enter your API key and secret. Fill in your credentials, hit Send, and see the response — no code needed. The request panel also shows generated code examples in many different languages.

How basic authentication works

Basic authentication sends your credentials as a Base64-encoded string in the Authorization header. The value of that header must be the literal string Basic followed by the Base64-encoded form of <my_username>:<my_password>. Use your API key as the username and your API secret as the password.

Most HTTP clients and libraries handle this natively. If yours doesn't, you can build the header yourself

Keep your credentials safe

The API uses an API key and secret for authentication. These credentials grant full access to your organization's data and must be kept confidential. Never expose them in client-side code such as a website's JavaScript — they belong on the server side only. See Authentication for details.

Using an API client

An API client is a library or tool that simplifies making requests to the API. Instead of constructing HTTP requests and parsing responses manually, a client handles those details for you. You can use any HTTP library in your language of choice to interact with the API.

Code examples

Your API base URL

The examples below use the production API URL (https://api.medipim.be/v4). If you want to use the sandbox environment, replace it with https://api.sandbox.medipim.be/v4. See Getting started for more details on environments.

curl

curl --user apiKeyId:apiKeySecret \
--location \
--request POST https://api.medipim.be/v4/brands/query

PHP (Medipim client)

If you are using PHP, we recommend using the Medipim API client.

<?php
$client = new \Medipim\Api\Client("apiKeyId", "apiKeySecret", "https://api.medipim.be");
$response = $client->post("/v4/brands/query");

PHP (cURL)

<?php
$h = curl_init("https://api.medipim.be/v4/brands/query");
curl_setopt($h, CURLOPT_USERPWD, "ApiKeyId:ApikeySecret");
curl_setopt($h, CURLOPT_RETURNTRANSFER, true);
curl_setopt($h, CURLOPT_HTTPHEADER, ["Content-type: application/json"]);
curl_setopt($h, CURLOPT_POSTFIELDS, json_encode([]));
$response = curl_exec($h);

Python

import http.client
import json

conn = http.client.HTTPSConnection("api.medipim.be")
payload = json.dumps({})
headers = {
'Content-Type': 'application/json',
# Base64-encoded "ApiKeyId:ApikeySecret"
'Authorization': 'Basic QXBpS2V5SWQ6QXBpa2V5U2VjcmV0'
}
conn.request("POST", "/v4/brands/query", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))