Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
Filtering REST API call to first result

I have a question that I feel should be pretty simple to answer, but I cannot find fix anywhere.

I'm querying the Uberchord website for guitar chords (documentation here)

Here is the URL I'm querying:

https://api.uberchord.com/v1/chords?nameLike=${variable}

Where variable is based on what the user types in.

The nameLike lets fuzzy match between the input and the API (For example, the url for an Fmaj7 chord is F_maj7). This works great, but it returns multiple responses. The first response is always the one I want, so I'm trying to just limit the responses to the first one that comes in. So far, I've tried adding a limit or a top filter to the URL to no avail. This is where I'm sure I'm doing something incorrect.

For limit, I've tried:

https://api.uberchord.com/v1/chords?nameLike=${fmaj7}?limit=1

and

https://api.uberchord.com/v1/chords?nameLike=${fmaj7}&limit=1

and for top I've done the same two but just replacing limit with top. The first one returns zero responses, while the second returns all responses.

Any ideas?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It isn't literally "returning multiple responses". It's just returning an array. It ALWAYS returns an array, even if there is only one element. If you only want the first element of that array, then fetch the first element of the array, just like you would with any other array. After you do the JSON decode:

   chord = response[0];
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!