1

My question is related to: Planet API not being accepted for quick search but is on stats and planet quick-search api not recognizing authentication?.

I am not able to successfully get a response from Planet 14 days trial API call for quick-search, I get the following error:

{'message': 'Please enter your API key, or email and password.', 'errors': []}

Edit1: my code is as follows:

 #AREA of Interest
geojson_geometry = {
  "type": "Polygon",
  "coordinates": [
    [ 
      [-19.423828125,-4.653079918274038],
      [51.591796875,-4.653079918274038],
      [51.591796875,45.336701909968134],
      [-19.423828125,45.336701909968134],
      [-19.423828125,-4.653079918274038]
    ]
  ]
}
#Images overlapping out area of interest
> geometry_filter = {
>     "type": "GeometryFilter",
>     "field_name": "geometry",
>     "config": geojson_geometry }

#for a specific date range

> date_range_filter = {
>     "type": "DateRangeFilter",
>     "field_name": "acquired",
>     "config": {
>         "gte": "2009-01-01T00:00:00.000Z",
>         "lte": "2019-03-31T00:00:00.000Z"
>     } }

#images with less than 50% cloud range

> cloud_cover_filter = {
>     "type": "RangeFilter",
>     "field_name": "cloud_cover",
>     "config": {
>         "lte": 0.5
>     } }

#combine geometry, date and cloud filters

> combined_filter = {
>     "type": "AndFilter",
>     "config": [geometry_filter, date_range_filter, cloud_cover_filter] }
> 
> import os import json import requests from requests.auth import
> HTTPBasicAuth

#PLANET_API_KEY = os.getenv('c43b6ae27338421dad81dd7c2a5306a6')

> os.environ["PLANET_API_KEY"] = "c43b6ae27338421dad81dd7c2a5306a6"
> 
> item_type = "PSScene4Band"

#API request object

> search_request = {
>     "interval": "day",
>     "item_types": [item_type],
>     "filter": combined_filter } 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))


  • Hey, welcome to GIS SE. Can you provide the code you are running to make the call? – Marcelo Villa Jul 8 at 14:31
0

It looks like your API Key is empty or null (my first guess) or invalid. You should follow these steps:

  1. Store your environmental variables outside your code. You can use something like this. Basically, create
#!/usr/bin/env bash
PLANET_API_KEY='YOUR_API_KEY'

Then before running your python script, execute the file.

  1. If the API Key you are sharing here is your real one, please edit your question and remove it. I would suggest also to regenerate.
  2. Replace this line...
os.environ["PLANET_API_KEY"] = "YOUR_API_KEY"

...with this other:

PLANET_API_KEY = os.environ["PLANET_API_KEY"]
  1. Run your python script.

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.