1. Home
  2. Docs
  3. API Documentation
  4. Welcome
  5. NewTarget Tutorial – An Example

NewTarget Tutorial – An Example

This is a tutorial meant to assist and demonstrate the use of CYTRIX’s API Client.

This tutorial is written in the Python programming language, but you can use any other language that matches the requirements.

apiKey Header

  • Add the following header “apiKey” to identify yourself to the API

Import the required Modules/Packages :

import requests

Define the Parameters (can also be done in a form of inputs to variables) :

parameters = {'target': 'desired_full_url', 'autoSpeed': 'on'}

Replace the Keys. For example: ‘your_api_key’ -> ‘aaa-1234-aaa-1234’ , ‘desired_full_url’ -> ‘https://example.com/’ etc…

Define any necessary Headers, Create the Request and save it into a Response :

headers = {'apiKey': 'xxxxx-xxxxx-xxxxx-xxxx','Content-Type': 'application/x-www-form-urlencoded'}
response = requests.post('https://api.cytrix.io/GetQueue', data=parameters, headers=headers)

The Content-Type with “application/json” must be used only for the “NewTarget” router

headers = {'apiKey': 'xxxxx-xxxxx-xxxxx-xxxx', 'Content-Type': 'application/json'}
response = requests.post('https://api.cytrix.io/NewTarget', json=parameters, headers=headers)

Print the text from the Response :

print(response.text)

On a Successful Response, a Text in a similar form will be displayed :

{“Error”: 0, “Function”: “NewTarget”, “Data”: [{“target”: “https://example.com/”, “status”: “OK”, “token”: “String…”}]}

Errors and their Possible Causes

For more information, please refer to the General Errors section.