Feeling frustrated & Using API's

Could you give me some tips on how to learn to make API requests? I was doing this lesson on codecademy for a bit and it turned out the information there was deprecated. I haven’t had any success with https://developer.mozilla.org or other websites that i’ve tried either. The information just seems so broad, and it feels like every site says something different. How did you learn them? Maybe you could give me some light guidance on the project in general? It seems so simple, i just lack the knowledge.

Thanks.

To use a REST API, you usually want to use at least three resources:

  • An API to get the data:
    • Vanilla JS:
      • fetch — newer, simpler, more modern, poorer support on old browsers, requires at least basic understanding of promises
      • XMLHttpRequest - old, clunky, more complicated, better support on old browsers, requires no knowledge of promises (but you still need to understand asynchronous functions and callbacks)
    • jQuery:
      • $.ajax — more versatile, slightly more complex (but still fairly simple)
      • $.getJSON — probably all you need if the resource is JSON
  • The documentation of the REST resource itself
  • Tinkering around with console.logging responses and figuring out their structure.

Personally, I’d recommend the fetch API, but either of the jQuery methods is fine too. Use MDN or jQuery’s own documentation accordingly.