Overview¶
These API docs are for the development teams who want to programatically configure their CodeREADr account or retrieve their scan data. Make sure to read this document before you get started.
Note: Use of our API is only available for accounts with a Paid Plan (https://www.codereadr.com/pricing/).
Finding Your API Key¶
A valid API key is required for any site functions performed through our API. To locate your API key, sign into CodeREADr.com or create an account. Once signed in your API key can be located or generated on the API Keys page under Account Settings (https://secure.codereadr.com/account/api/key).
Submitting Variables¶
The codeREADr API is located at:
https://api.codereadr.com/api/https://barcode.codereadr.com/api/(Barcode Generator API)
Every function performed through the API requires at least these three variables to be submitted:
| Variable | Description |
|---|---|
section | A string specifying the section of your account you wish to configure. |
action | A string specifying the action you wish to perform on that area. |
api_key | A string with your unique API key. For security reasons, including the api_key directly in the URL via GET requests is strongly discouraged and GET requests are not enabled by default. Please contact our support team to request temporary GET access for testing purposes only. For production environments, we recommend using POST requests. |
You can submit variables using the following methods:
GET (URL Query) (Disabled by Default for Security)¶
Important
For security reasons, including your api_key in the URL is not recommended. GET requests are disabled by default. To enable GET requests for testing purposes only, please contact our support team.
Default API Example (GET - Disabled by Default):
Barcode Generator API Example (GET - Disabled by Default):
POST (Form Encoded) (Recommended)¶
We recommend using the POST method to submit your API key securely. Variables can be sent in the application/x-www-form-urlencoded format in the request body.
Example using curl:
curl -X POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "api_key=YOUR_API_KEY§ion=SECTION_VARIABLE&action=ACTION_VARIABLE" \
https://api.codereadr.com/api/
Example using Python (with requests library):
import requests
url = "https://api.codereadr.com/api/"
data = {
"api_key": "YOUR_API_KEY",
"section": "SECTION_VARIABLE",
"action": "ACTION_VARIABLE"
}
response = requests.post(url, data=data)
print(response.text)
Example using Node.js (with node-fetch library):
const fetch = require('node-fetch');
const url = "https://api.codereadr.com/api/";
const data = new URLSearchParams();
data.append('api_key', 'YOUR_API_KEY');
data.append('section', 'SECTION_VARIABLE');
data.append('action', 'ACTION_VARIABLE');
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: data,
})
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.error('Error:', error));
Example using PHP (with cURL library):
<?php
$url = "https://api.codereadr.com/api/";
$data = array(
"api_key" => "YOUR_API_KEY",
"section" => "SECTION_VARIABLE",
"action" => "ACTION_VARIABLE"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
Example using Java (with java.net.http):
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.net.URLEncoder;
import java.io.IOException;
public class ApiRequest {
public static void main(String[] args) throws IOException, InterruptedException {
String url = "https://api.codereadr.com/api/";
String apiKey = "YOUR_API_KEY";
String section = "SECTION_VARIABLE";
String action = "ACTION_VARIABLE";
String formData = URLEncoder.encode("api_key", StandardCharsets.UTF_8) + "=" + URLEncoder.encode(apiKey, StandardCharsets.UTF_8) +
"&" + URLEncoder.encode("section", StandardCharsets.UTF_8) + "=" + URLEncoder.encode(section, StandardCharsets.UTF_8) +
"&" + URLEncoder.encode("action", StandardCharsets.UTF_8) + "=" + URLEncoder.encode(action, StandardCharsets.UTF_8);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/x-www-form-urlencoded")
.POST(HttpRequest.BodyPublishers.ofString(formData))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Example using HTML Form:
Create an HTML file formatted like the example below, insert your variables, and open the file in your browser to send your variables.
<html>
<form method="POST" action="https://api.codereadr.com/api/">
<input type="hidden" name="api_key" value="YOUR_API_KEY"/>
<input type="text" name="section" value="SECTION_VARIABLE"/>
<input type="text" name="action" value="ACTION_VARIABLE"/>
<input type="submit"/>
</form>
</html>
Build an XML file to post to https://api.codereadr.com/api/. Only one file can be submitted - if you submit several files, only one will be processed and the rest ignored. The Content-Type for this request should be application/xml.
Example:
<xml>
<section>SECTION_VARIABLE</section>
<action>ACTION_VARIABLE</action>
<api_key>YOUR_API_KEY</api_key>
</xml>
Example using curl to send an XML file:
curl -X POST \
-H "Content-Type: application/xml" \
-d "@your_file.xml" \
https://api.codereadr.com/api/
You can also build an XML string, assign it to the variable named xml, and either send it via POST. Sending XML strings via GET is not recommended due to potential URL length limitations and the security concerns mentioned earlier.
Example using POST with XML String:
curl -X POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "xml=<xml><section>SECTION_VARIABLE</section><action>ACTION_VARIABLE</action><api_key>YOUR_API_KEY</api_key></xml>" \
https://api.codereadr.com/api/
After the API receives the request, it responds with raw XML containing either a success status and requested information, or a failure status and an error description.