Adding multiple drivers to your team
Here we will be using Drivers Import endpoint to create multiple drivers in your team. Read their descriptions to see all the available aptions.
- JS Web
- Node
- Python
- curl
// Set the API key
const apiKey = '<your-api-key>'
// Headers for the request
const headers = new Headers()
headers.append('Content-Type', 'application/json')
headers.append('Authorization', `Basic ${btoa(`${apiKey}:`)}`)
async function createDrivers() {
// The driver emails. Email or phone number is the minimum
// information needed to create a driver, for it will
// be used as their login method.
const requestPayload = [
{"email": "john.doe@example.com"},
{"email": "max.mustermann@example.com"},
{"email": "fulano.silva@example.com"}
]
// Perform the request with POST method
const response = await fetch(
'https://api.getcircuit.com/public/v0.2b/drivers:import',
{
method: 'POST',
headers: headers,
body: JSON.stringify(requestPayload),
},
)
// The response will return an object similar to the following:
// {
// "success": [
// "drivers/NTenthoECOENoenoeEOc",
// "drivers/EteR5453oeinXEnecto6",
// "drivers/teROOSvDTE5Ete566eou"
// ],
// "failed": []
// }
const driverIds = (await response.json()).success
console.log(driverIds)
// If you wish to retrieve more information about one of the create drivers you can
// issue a GET request for it:
const driverGetResponse = await fetch(
`https://api.getcircuit.com/public/v0.2b/${driverIds[0]}`,
{
headers: new Headers({
Authorization: `Basic ${btoa(`${apiKey}:`)}`,
}),
},
)
// The response will return information about the driver.
const driverData = await driverGetResponse.json()
console.log(driverData)
}
// We are using the axios library here to make requests from Node
const axios = require('axios')
const apiKey = '<your-api-key>'
async function createDrivers() {
// The driver emails. Email or phone number is the minimum
// information needed to create a driver, for it will
// be used as their login method.
const requestPayload = [
{"email": "john.doe@example.com"},
{"email": "max.mustermann@example.com"},
{"email": "fulano.silva@example.com"}
]
// Perform the request with POST method
const response = await axios.post(
'https://api.getcircuit.com/public/v0.2b/drivers:import',
requestPayload,
{
auth: { username: apiKey }
}
)
// The response will return an object similar to the following:
// {
// "success": [
// "drivers/NTenthoECOENoenoeEOc",
// "drivers/EteR5453oeinXEnecto6",
// "drivers/teROOSvDTE5Ete566eou"
// ],
// "failed": []
// }
const driverIds = response.data.success
console.log(driverIds)
// If you wish to retrieve more information about one of the create drivers you can
// issue a GET request for it:
const driverGetResponse = await axios.get(
`https://api.getcircuit.com/public/v0.2b/${driverIds[0]}`,
{
auth: { username: apiKey },
},
)
// The response will return information about the driver.
const driverData = await driverGetResponse.json()
console.log(driverData)
}
# We are using the requests library here to make requests from Python
import requests
from requests.auth import HTTPBasicAuth
# Set the API key
api_key = "<your-api-key>"
# The driver emails. Email or phone nuber is the minimum
# information needed to create a driver, for it will
# be used as their login method.
request_payload = [
{"email": "john.doe@example.com"},
{"email": "max.mustermann@example.com"},
{"email": "fulano.silva@example.com"}
]
# Perform the request with POST method
response = requests.post(
"https://api.getcircuit.com/public/v0.2b/drivers:import",
auth=HTTPBasicAuth(api_key, ""),
json=request_payload,
)
# The response will return an object similar to the following:
# {
# "success": [
# "drivers/NTenthoECOENoenoeEOc",
# "drivers/EteR5453oeinXEnecto6",
# "drivers/teROOSvDTE5Ete566eou"
# ],
# "failed": []
# }
driver_ids = response.json()['success']
print(driver_ids)
# If you wish to retrieve more information about one of the create drivers you can
# issue a GET request for it:
driver_get_response = requests.get(
f'https://api.getcircuit.com/public/v0.2b/{driver_ids[0]}',
auth=HTTPBasicAuth(api_key, ""),
)
# The response will return information about the stop.
driver_info = driver_get_response.json()
print(driver_info)
# The driver emails. Email or phone number is the minimum
# information needed to create a driver, for it will
# be used as their login method.
request_payload='[
{"email": "john.doe@example.com"},
{"email": "max.mustermann@example.com"},
{"email": "fulano.silva@example.com"}
]'
curl -X POST https://api.getcircuit.com/public/v0.2b/drivers:import \
-d "$request_payload" \
-H 'Content-Type: application/json' \
-u <your-api-key>:
# The response will have an object similar to the following:
# {
# "success": [
# "drivers/NTenthoECOENoenoeEOc",
# "drivers/EteR5453oeinXEnecto6",
# "drivers/teROOSvDTE5Ete566eou"
# ],
# "failed": []
# }
# If you wish to retrieve more information about one of the created drivers you can
# issue a GET request for it:
curl https://api.getcircuit.com/public/v0.2b/drivers/teROOSvDTE5Ete566eou \
-u <your-api-key>: