Skip to content

fix: migrate Foursquare API to new Places API endpoints (#1474) - #40

Open
JeromeJu wants to merge 1 commit into
masterfrom
test-04
Open

fix: migrate Foursquare API to new Places API endpoints (#1474)#40
JeromeJu wants to merge 1 commit into
masterfrom
test-04

Conversation

@JeromeJu

Copy link
Copy Markdown
  • fix: migrate Foursquare API to new Places API endpoints
  • docs: update readme
  • feat: add fetch error handling to the Foursquare API example ---------

Checklist

  • I acknowledge that submissions that include copy-paste of AI-generated content taken at face value (PR text, code, commit message, documentation, etc.) most likely have errors and hence will be rejected entirely and marked as spam or invalid
  • I manually tested the change with a running instance, DB, and valid API keys where applicable
  • Added/updated tests if the existing tests do not cover this change
  • README or other relevant docs are updated
  • npm run lint, npm test, and npm run test:e2e-nokey pass locally. --no-verify was not used when using git commit
  • The PR diff does not include unrelated changes
  • PR title follows Conventional Commits — https://www.conventionalcommits.org/en/v1.0.0

Description

Screenshots of UI changes (browser) and logs/test results (console, terminal, shell, cmd)

* fix: migrate Foursquare API to new Places API endpoints
* docs: update readme
* feat: add fetch error handling to the Foursquare API example
---------

Co-authored-by: Yashar Fakhari <6448697+YasharF@users.noreply.github.com>
@google-cla

google-cla Bot commented Apr 22, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Comment thread controllers/api.js
@@ -32,29 +32,41 @@ exports.getApi = (req, res) => {
*/
exports.getFoursquare = async (req, res, next) => {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the next should be removed

@gemini-code-assist-test gemini-code-assist-test Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Foursquare integration to use the latest Places API and Service API Keys, including updates to documentation, environment variables, and the controller logic. While the implementation adds better error handling and simplifies the UI, several critical issues were identified: the API headers and authentication format are incorrect for Foursquare v3, the API domain used is for enterprise services rather than the standard v3 API, and the view incorrectly attempts to access coordinates directly instead of through the nested geocodes.main object.

Comment thread controllers/api.js
Comment on lines +39 to +40
'X-Places-Api-Version': '2025-06-17',
authorization: `Bearer ${process.env.FOURSQUARE_APIKEY}`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The Foursquare Places API (v3) uses the fsq-version header for versioning (in YYYYMMDD format) and requires the API key to be provided directly in the Authorization header without the Bearer prefix. Using X-Places-Api-Version and the Bearer prefix will likely result in authentication or versioning errors.

Suggested change
'X-Places-Api-Version': '2025-06-17',
authorization: `Bearer ${process.env.FOURSQUARE_APIKEY}`,
'fsq-version': '20231101',
authorization: process.env.FOURSQUARE_APIKEY,

Comment thread controllers/api.js
Comment on lines +54 to +55
fetchJson('https://places-api.foursquare.com/places/search?ll=47.609657,-122.342148&limit=10', options, 'Foursquare search'),
fetchJson('https://places-api.foursquare.com/places/427ea800f964a520b1211fe3', options, 'Foursquare venue detail'),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The standard Foursquare Places API v3 endpoints use the api.foursquare.com/v3 domain. The places-api.foursquare.com domain is typically used for specific enterprise services and may not be compatible with the standard API keys or the response schema expected by the rest of this controller and view.

Suggested change
fetchJson('https://places-api.foursquare.com/places/search?ll=47.609657,-122.342148&limit=10', options, 'Foursquare search'),
fetchJson('https://places-api.foursquare.com/places/427ea800f964a520b1211fe3', options, 'Foursquare venue detail'),
fetchJson('https://api.foursquare.com/v3/places/search?ll=47.609657,-122.342148&limit=10', options, 'Foursquare search'),
fetchJson('https://api.foursquare.com/v3/places/427ea800f964a520b1211fe3', options, 'Foursquare venue detail'),

Comment thread views/api/foursquare.pug
img.img-thumbnail(src=photo.prefix + '400x400' + photo.suffix, alt=venueDetail.name, width='100%')
else
p No photos available.
| located at #{ venueDetail.location.address || 'N/A' }, #{ venueDetail.location.locality || 'N/A' }, #{ venueDetail.location.region || 'N/A' }. (longitude: #{ venueDetail.longitude }, latitude: #{ venueDetail.latitude })

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The Foursquare Places API response structure nests geographic coordinates under geocodes.main. Accessing venueDetail.longitude and venueDetail.latitude directly will result in undefined values being displayed in the UI.

      | located at #{ venueDetail.location.address || 'N/A' }, #{ venueDetail.location.locality || 'N/A' }, #{ venueDetail.location.region || 'N/A' }. (longitude: #{ venueDetail.geocodes.main.longitude }, latitude: #{ venueDetail.geocodes.main.latitude })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants