pythonapipython-requestsfoursquare

Python Foursquare API request error when trying to get venue details


I try to make a request from the foursquare api. If I change the request URL it does no longer get me a result

when I make a request with this line of code everything is fine:

def venue_details():
    detail_results = requests.get('https://api.foursquare.com/v2/venues/4e96cf73b8f7d8c690f48384/?client_id=[my client id]&client_secret=[my client secret]&v=20180604').json()

When I make a request with this line of code I get an error:

`VENUE_ID = '4e96cf73b8f7d8c690f48384'
CLIENT_ID = '[my client id]'
CLIENT_SECRET = '[my client secret]'
VERSION = '20180604'


url = 'https://api.foursquare.com/v2/venues/?venue_id={}/?client_id={}&client_secret={}&v={}'.format(
VENUE_ID,
CLIENT_ID, 
CLIENT_SECRET, 
VERSION
)

detail_results = requests.get(url).json()
{'meta': {'code': 400,
  'errorType': 'invalid_auth',
  'errorDetail': 'Missing access credentials. See https://developer.foursquare.com/docs/api/configuration/authentication for details.',
  'requestId': '63623c5231edc703599dc1da'},
 'response': {}}

I think I get the authentication error because it stops reading the url at "?venue_id"


Solution

  • I can see that you are using the legacy version of our Places API which now has limited support. Please switch to use v3 --> https://api.foursquare.com/v3/places/search

    Our documentation should get you started --> https://location.foursquare.com/developer/reference/place-search

    Please join our Discord if you need more direct help --> https://discord.gg/foursquaredevs