The AirMap Pilot API allows your application to retrieve and interact with pilot (user) profiles on the AirMap platform.
Get Pilot Profile
## Get pilot profile information with the [`/pilot/:id`](https://developers.airmap.com/reference#pilot-profile-details) endpoint:
curl -X "GET" "https://api.airmap.io/pilot/v2/{PILOT ID}" \
-H "Authorization: Bearer {YOUR ACCESS TOKEN}" \
-H "X-API-Key: {YOUR API KEY}"
## The response contains the pilot's profile:
{
"status": "success",
"data": {
"id": "kc|0ca2d34c-1bf6-4204-9f3a-e248cce4ddcb",
"email": "[email protected]",
"first_name": "Joe",
"last_name": "Nobody",
"username": "my_new_username",
"picture_url": "",
"phone": "+1 310-555-5555",
"app_metadata": {},
"created_at": "2019-10-02T00:48:17.285Z",
"verification_status": {
"email": true,
"phone": true
},
"statistics": {
"flight": {
"total": 40481,
"last_flight_time": "2020-03-21T02:55:55.000Z"
},
"aircraft": {
"total": 1
}
},
"user_metadata": {}
}
}
AirMap.getPilot(by: <#T##Pilot Identifier#>) { result in
case .error(let error):
// Handle error case
print(error)
case .value(let pilot):
// Handle success case
}
}
AirMap.getPilot(pilotId, new AirMapCallback<AirMapPilot>() {
@Override
protected void onSuccess(AirMapPilot pilot) {
// Handle success
}
@Override
protected void onError(AirMapException e) {
// Handle error
}
});
Note
When requesting a pilot's profile there are two types of responses: public and full. The public profile does not expose any contact information and is very limited (
id
andstatistics
only). The full profile, only accessible if authenticated as the requested pilot, returns all stored information.
API Key | Token | Profile Type |
---|---|---|
Yes | No | Public |
Yes | Same as requested pilot | Full |
Yes | Different than requested pilot | Public |
Update a Pilot Profile
## A pilot's profile can be updated via a `PATCH` to `/pilot/:id`.
## Below is the initial `PATCH` TO `/pilot/v2/:id` to update the phone number:
curl -X "PATCH" "https://api.airmap.io/pilot/v2/{PILOT ID}" \
-H "X-API-Key: {YOUR API KEY}" \
-H "Authorization: Bearer {YOUR ACCESS TOKEN}" \
-H "Content-Type: application/json; charset=utf-8" \
-d "{\"phone\":\"+13109234698\"}"
## The response confirms the updated information:
{
"status": "success",
"data": {
"phone": "+13109234698"
}
}
AirMap.updatePilot(<#T##pilot: AirMapPilot##AirMapPilot#>) { result in
case .error(let error):
// Handle error case
print(error)
case .value(let pilot):
// Handle success case
}
}
AirMap.updatePilot(pilot, new AirMapCallback<AirMapPilot>() {
@Override
protected void onSuccess(AirMapPilot response) {
// Handle success
}
@Override
protected void onError(AirMapException e) {
// Handle error
}
});
A pilot's phone number and email are essential to communication and are required to be verified when they are first provided or any time they are updated.
Validating a Phone Number
Send a phone verification token to the pilot:
curl -X "POST" "https://api.airmap.io/pilot/v2/{PILOT ID}/phone/send_token" \
-H "X-API-Key: {YOUR API KEY}" \
-H "Authorization: Bearer {YOUR ACCESS TOKEN}" \
-H "Content-Type: application/json; charset=utf-8" \
-d "{}"
AirMap.sendSMSVerificationToken { (result) in
switch result {
case .error(let error):
// Handle error case
print(error)
case .value:
// Handle success case
}
}
}
AirMap.sendVerificationToken(new AirMapCallback<Void>() {
@Override
protected void onSuccess(Void response) {
// Handle success
}
@Override
protected void onError(AirMapException e) {
// Handle error
}
});
Once a verification token is received create a POST
request to /pilot/v2/:id/phone/verify_token
with the provided verification token:
curl -X "POST" "https://api.airmap.io/pilot/v2/{PILOT ID}/phone/verify_token" \
-H "X-API-Key: {YOUR API KEY}" \
-H "Authorization: Bearer {YOUR ACCESS TOKEN}" \
-H "Content-Type: application/json; charset=utf-8" \
-d "{\"token\":\"{VERIFICATION TOKEN}\"}"
## Once verified, a successful verification response is received:
{
"status": "success",
"data": {
"verified": true
}
}
## You have one opportunity to verify the update. If the verification fails for any reason, you must request an additional verification token via the `/pilot/v2/:id/phone/send_token` route.
AirMap.verifySMS(<#T##token: String##String#>) { result in
switch result {
case .error(let error):
// Handle error case
print(error)
case .value(let pilotVerified):
// Handle success case
}
}
AirMap.verifyPhoneToken(token, new AirMapCallback<Boolean>() {
@Override
protected void onSuccess(Boolean verified) {
}
@Override
protected void onError(AirMapException e) {
}
});
Updated 3 years ago