2

I can successfully reproduce the first two API calls from this walkthrough: https://www.planet.com/docs/api-quickstart-examples/step-1-search/ (as I have an API key). However, the third call (the POST to 'https://api.planet.com/data/v1/quick-search') gives me:

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

I have copied and pasted everything from this example.

Is this expected because I am a free user?

EDIT - Responding to Richard Law - Yes, I have a mac and echo $PLANET_API_KEY shows me my key. As would be expected given the fact that the first two calls worked..

EDIT #2 - Responding to Bosth - I can show you my code, but it really is not that interesting because it's the exact same code as the example. Here it is. I'm running the two requests in one script to make sure it's the same environment..

import os
import requests
from requests.auth import HTTPBasicAuth

geo_json_geometry = {
  "type": "Polygon",
  "coordinates": [
    [
      [
        -122.52227783203125,
        40.660847697284815
      ],
      [
        -122.52227783203125,
        40.987154933797335
      ],
      [
        -122.01690673828124,
        40.987154933797335
      ],
      [
        -122.01690673828124,
        40.660847697284815
      ],
      [
        -122.52227783203125,
        40.660847697284815
      ]
    ]
  ]
}

# filter for items the overlap with our chosen geometry
geometry_filter = {
  "type": "GeometryFilter",
  "field_name": "geometry",
  "config": geo_json_geometry
}

# filter images acquired in a certain date range
date_range_filter = {
  "type": "DateRangeFilter",
  "field_name": "acquired",
  "config": {
    "gte": "2016-07-01T00:00:00.000Z",
    "lte": "2016-08-01T00:00:00.000Z"
  }
}

# filter any images which are more than 50% clouds
cloud_cover_filter = {
  "type": "RangeFilter",
  "field_name": "cloud_cover",
  "config": {
    "lte": 0.5
  }
}

# create a filter that combines our geo and date filters
# could also use an "OrFilter"
redding_reservoir = {
  "type": "AndFilter",
  "config": [geometry_filter, date_range_filter, cloud_cover_filter]
}

stats_endpoint_request = {
  "interval": "day",
  "item_types": ["REOrthoTile"],
  "filter": redding_reservoir
}

# fire off the POST request
result = \
  requests.post(
    'https://api.planet.com/data/v1/stats',
    auth=HTTPBasicAuth(os.environ['PLANET_API_KEY'], ''),
    json=stats_endpoint_request)

print result.text
print

# Search API request object
search_endpoint_request = {
  "item_types": ["REOrthoTile"],
  "filter": redding_reservoir
}

result = \
  requests.post(
    'https://api.planet.com/data/v1/quick-search',
    auth=HTTPBasicAuth(os.environ['PLANET_API_KEY'], ''),
    json=search_endpoint_request)

print result.text

Result from running code: screenshot

  • 1
    Just to check, you set PLANET_API_KEY as an environment variable called exactly that? Can you see the value if you do echo $PLANET_API_KEY (or whatever the Windows equivalent to that is)? – alphabetasoup May 7 '17 at 21:06
  • 1
    @Adam I suggest you merge your two accounts. gis.stackexchange.com/help/merging-accounts – Fezter May 9 '17 at 5:01
  • Interesting. I will note that the script works for me with what I think of as my personal open california key. It might be subtle aspect of the permissions of your key. If you want to email me at frank@planet.com with your key, I can try it in place of mine and see what happens. – Frank Warmerdam May 9 '17 at 6:18
  • @bosth I am now facing a same problem with my account, I receive a response to api.planet.com/data/v1/stats using my api call however I face the following error during api.planet.com/data/v1/quick-search: > { "message": "Please enter your API key, or email and password.", > "errors": [] } Please advice. – Kiran Chhatre Jul 8 at 13:26
1

This is not expected. All accounts with Planet have the same access to the full metadata catalog; the only difference in restrictions is on downloading actual data.

According to the question the following code worked fine:

result = \
  requests.post(
    'https://api.planet.com/data/v1/stats',
    auth=HTTPBasicAuth(os.environ['PLANET_API_KEY'], ''),
    json=stats_endpoint_request)
print result.text

But this did not:

result = \
   requests.post(
     'https://api.planet.com/data/v1/quick-search',
     auth=HTTPBasicAuth(os.environ['PLANET_API_KEY'], ''),
     json=search_endpoint_request)
print result.text

This does suggest that PLANET_API_KEY is not available in the second instance that you are running the code.

It would help clarify if the working and non-working code was posted as part of the question.

UPDATE I was able to reproduce the issue with the code provided and your API key. Further investigation showed that a flag in your account was misconfigured; I have just fixed it and API calls will now work.

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.