1

I am following the method as shown in the Python notebook here to download Planet satellite data from their API.

But, I am getting an error after I run the following piece of code:

import os
import json
import requests
from requests.auth import HTTPBasicAuth

# API Key stored as an env variable
PLANET_API_KEY = os.getenv('PL_API_KEY')

item_type = "PSScene4Band"

# API request object
search_request = {
  "interval": "day",
  "item_types": [item_type], 
  "filter": combined_filter
}

# fire off the POST request
search_result = \
  requests.post(
    'https://api.planet.com/data/v1/quick-search',
    auth=HTTPBasicAuth(PLANET_API_KEY, ''),
    json=search_request)

print(json.dumps(search_result.json(), indent=1))

Error:

{
 "message": "Please enter your API key.",
 "errors": []
}

I checked for the API key by doing echo $PL_API_KEY and it produced the correct API key.

How can I figure this out so that I can download data from Planet API?

1
  • I'm not a Planet user, but perhaps you need to include the API key as a URL parameter; it's not really basic auth (which should be user/password). A quick scan of the documentation suggests you should be using an Authorization header, with a value like api-key {your-api-key} May 31 at 3:02
0

Did you verified your API-key is valid and active? It could be done either with Planet Explorer
or in your Planet account.

The API documentation or this example of a Jupyter notebook with Python should help you.

1
  • Yes. I verified the KEY by echo $PL_API_KEY.
    – user168115
    Aug 5 '20 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.