Title: REST API Javascript documentation?
Last modified: September 10, 2021

---

# REST API Javascript documentation?

 *  [paddletroke](https://wordpress.org/support/users/paddletroke/)
 * (@paddletroke)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/rest-api-javascript-documentation/)
 * Hello,
    I’m making a webapp based on wordpress in which I’m using the REST API
   for my users to get and create posts.
 * I found the very useful [REST API backbone javascript client](https://developer.wordpress.org/rest-api/using-the-rest-api/backbone-javascript-client/)
   which is great.
    However the documentation in this link is limited to only a 
   few selected examples.
 * Do you know if there is a more complete documentation? With more examples?
    For
   example : How would you fetch the post of the current logged in user?
 * Thanks!

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

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/rest-api-javascript-documentation/#post-14859418)
 * Have you seen [https://developer.wordpress.org/rest-api/](https://developer.wordpress.org/rest-api/)?
 * The examples in the endpoint reference are extremely terse, but they are there.
   There are also examples in the other sections that are more meaningful, but they
   are limited in applicability.
 * To get logged in user posts you’d need their ID. Then you’d do something like
   
   example.com/wp-json/wp/v2/posts?author=123
 * example.com/wp-json/wp/v2/users/me I believe will give you current user data.
   You do need to send an appropriate authentication nonce to get this data. Refer
   to the authentication section of the API docs I linked above.
 *  Thread Starter [paddletroke](https://wordpress.org/support/users/paddletroke/)
 * (@paddletroke)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/rest-api-javascript-documentation/#post-14859846)
 * Hi,
    Thanks for the reply. I found some solutions today.
 * Here’s some examples for WP-API backbone JS client. It may help others :
 * Fetch post of a certain author and category :
 *     ```
       var filteredPosts = new wp.api.collections.Posts();
       authorsPosts.fetch({ data: { author: currentUserId, categories: 42 } }).then( posts => { 
           for(const post of posts){
               //do stuff with each post
           }
       } );
       ```
   
 * Update a post :
 *     ```
       var post = new wp.api.models.Post( { 
           id: idOfThePostYouWantToUpdate,
           title: newTitle,
           content: newContent,
           status: newStatus,
           categories: [ 42 ],
           tags: [ 50 ]
           });
       post.save();
       ```
   
    -  This reply was modified 4 years, 9 months ago by [paddletroke](https://wordpress.org/support/users/paddletroke/).

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

The topic ‘REST API Javascript documentation?’ is closed to new replies.

## Tags

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

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [paddletroke](https://wordpress.org/support/users/paddletroke/)
 * Last activity: [4 years, 9 months ago](https://wordpress.org/support/topic/rest-api-javascript-documentation/#post-14859846)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
