Viewing Pilot Profiles

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": "auth0|57684b10e5bd9lda040e5962",
    "email": "user@airmap.com",
    "first_name": "Joe",
    "last_name": "Smith",
    "username": "jsmith",
    "picture_url": "https://s.gravatar.com/avatar/ed46eb60eae16e1822b92779e5380e1c?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fca.png",
    "phone": "+13109256785",
    "user_metadata": {
      "faa_registration_number": ""
    },
    "app_metadata": {},
    "created_at": "2016-06-20T19:59:12.920Z",
    "verification_status": {
      "email": true,
      "phone": true
    },
    "statistics": {
      "flight": {
        "total": 5,
        "last_flight_time": "2016-08-10T00:30:00.000Z"
      },
      "aircraft": {
        "total": 2
      }
    }
  }
}
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. 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) {

    }
});

What's Next

View and make edits to the pilot's aircraft.

Accessing Pilot Aircraft

Viewing Pilot Profiles