userid and apikey will be provided privately. Do not share them publicly.
Include your API key in the query string:
POST /api.php?apikey=YOUR_API_KEY
POST a JSON array of drug records to the endpoint:
https://apirefill.careposting.com/api.php?apikey=YOUR_API_KEY
Send an array of JSON objects. Each object must include:
drugname (string)userid (integer)nooftablets (integer)type (string)purchasecost (float)salescost (float)discount (float)expirydate (string)category (string)[
{
"drugname": "Paracetamol",
"userid": 1,
"nooftablets": 100,
"type": "Tablet",
"purchasecost": 50,
"salescost": 80,
"discount": 5,
"expirydate": "2025-08-01",
"category": "Laxitive"
},
{
"drugname": "Ibuprofen",
"userid": 1,
"nooftablets": 50,
"type": "Capsule",
"purchasecost": 30,
"salescost": 60,
"discount": 3,
"expirydate": "2025-08-01",
"category": "Laxitive"
}
]
The API returns a summary like this:
{
"API Response": [
{ "index":Ibuprofen, "status": "updated" },
{ "index": Paracetamol, "status": "inserted" }
]
}
{ "error": "Unauthorized" }
{ "error": "Invalid input format. Expected an array of records." }
This script connects to a specified database table, checks for updated rows (based on an updated_at column), converts the data into a structured JSON array, and sends it via POST to the Refill API.
localhostexternal_dbrootpasswordexternal_inventoryThe script checks for records updated in the last 10 minutes. This interval is adjustable with the $checkWindowMinutes variable inside the script.
The source table should contain the following fields:
drugnameuseridnooftabletstypepurchasecostsalescostdiscountupdated_at (required for tracking changes)[
{
"drugname": "Paracetamol",
"userid": 1,
"nooftablets": 100,
"type": "Tablet",
"purchasecost": 50,
"salescost": 80,
"discount": 5,
"expirydate": "2025-08-01",
"category": "Laxitive"
},
{
"drugname": "Ibuprofen",
"userid": 1,
"nooftablets": 50,
"type": "Capsule",
"purchasecost": 30,
"salescost": 60,
"discount": 3,
"expirydate": "2025-08-01",
"category": "Laxitive"
}
]
The script posts the data to:
https://apirefill.careposting.com/api.php?apikey=SECRET_API_KEY_123
apikey and Userid will be shared with authorized systems only.
Perfect for syncing pharmacy data from third-party inventory systems into your central Refill system automatically.
Run this script via a cron job every 5โ10 minutes to keep records in sync:
*/10 * * * * /usr/bin/php /path/to/post_to_apidb.php