Making Your First Request
Call Structure
The Public API's REST calls include URL for the environment:
- Live -
https://dsapi.directscale.com/v1
- Stage -
https://dsapi-stage.directscale.com/v1
For best practice, you'll use the Stage environment for all your testing.
You'll include your API Key and Content-Type in the Headers as shown in the following call examples:
curl --request GET \
--url https://dsapi.directscale.com/v1/customers/299/countries \
--header 'Accept: application/json' \
--header 'Ocp-Apim-Subscription-Key: dedfe8bc2c1448e7b2af7d1ad95a03c4'
var client = new RestClient("https://dsapi.directscale.com/v1/customers/299/countries");
var request = new RestRequest(Method.GET);
request.AddHeader("Accept", "application/json");
request.AddHeader("Ocp-Apim-Subscription-Key", "dedfe8bc2c1448e7b2af7d1ad95a03c4");
IRestResponse response = client.Execute(request);
const options = {
method: 'GET',
headers: {
Accept: 'application/json',
'Ocp-Apim-Subscription-Key': 'dedfe8bc2c1448e7b2af7d1ad95a03c4'
}
};
fetch('https://dsapi.directscale.com/v1/customers/299/countries', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
The example shows the call for Get Customer Countries. Let's break this call down:
GET https://dsapi.directscale.com/v1/customers/299/countries
GET
- HTTP Verbhttps://dsapi.directscale.com
- Hostv1
- Versioncustomers
- API299
- request parameter. In this example, it's thecustomerId
.countries
- Endpoint
For Get Customer Countries endpoint, you simply pass in an Associate's customerId
as a request parameter. If valid, the 200 OK response payload looks like this:
X-DirectScale-RequestId: ddca4806-ce2b-4bb1-8b1f-fe8acef0ca7e
Date: Fri, 16 Jul 2021 20:47:29 GMT
Content-Length: 284
Content-Type: application/json
[{
"CountryId": 0,
"CountryCode": "us",
"Shop": true,
"Enroll": true,
"CurrencyCode": "USD",
"AddTax": false,
"TaxRate": 0.0,
"RequireFin": true,
"CountryName": "United States",
"ISO3": "USA",
"CountryLanguages": null
}]
For reference, the parameters are the same as the fields used to add a country in Corporate Admin.
Using the API Gateway to Test
With your account, you have access to the API Gateway for both Live and Stage. This site features documentation and a handy Try it Now tool. This feature allows you to test every endpoint available right from your browser.
- Navigate to https://apigateway-stage.directscale.com
- Log in.
- Click the APIs tab.
- Locate an endpoint you want to test. You can start with a simple one like Customers > Get Customer.
- Read the endpoint's documentation and not the request parameters. You may need to fetch them via another endpoint or using the Corporate Admin. Read our Glossary for more information.
- Click the Try it Now button. You'll navigate to the testing portal.
- Enter the request parameters and select your Subscription key (API Key).
- Click Send.
Updated over 3 years ago