Title: API Tutorials?
Last modified: June 30, 2021

---

# API Tutorials?

 *  Resolved [Ed Sutherland](https://wordpress.org/support/users/upstateny/)
 * (@upstateny)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/api-tutorials/)
 * I want to use an API from organizations such as OpnStates.org to display state
   legislator information. There are some brief instructions, but not how to implement
   an API call in WordPress.
 * “Each of these methods are simple GET requests that return JSON with meaningful
   error codes/etc. So if the GraphQL of v2 was overwhelming, this should be easier
   to use.”
 * For instance, this is the [interactive page](https://v3.openstates.org/docs#/people/people_search_people_get)
   for the /people GET.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Alan Fuller](https://wordpress.org/support/users/alanfuller/)
 * (@alanfuller)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/api-tutorials/#post-14613115)
 * You would use wp_remote_get() – see [https://developer.wordpress.org/reference/functions/wp_remote_get/](https://developer.wordpress.org/reference/functions/wp_remote_get/)
 * rather like this untested example using the docs above
 *     ```
       $url  = "https://v3.openstates.org/jurisdictions';
       $args = array(
         'headers' => array (
            'X-API-KEY' => 'your api key here'
          ),
       );
   
       $response         = wp_remote_get(  $url, $args );
       $response_code    = wp_remote_retrieve_response_code( $response );
       if ( 200 != $response_code ) {
       			// handle non sucess  e.g. error_log
       }
       $decoded = json_decode( wp_remote_retrieve_body( $response ), true );   // decodes json into an array
       ```
   
 *  Thread Starter [Ed Sutherland](https://wordpress.org/support/users/upstateny/)
 * (@upstateny)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/api-tutorials/#post-14613958)
 * Thanks, Alan.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘API Tutorials?’ is closed to new replies.

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [Ed Sutherland](https://wordpress.org/support/users/upstateny/)
 * Last activity: [4 years, 11 months ago](https://wordpress.org/support/topic/api-tutorials/#post-14613958)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
