Example: Syncing Orders

There are two ways to sync orders from Reverb to your application:

  • Pulling orders based on dates
  • Using webhooks

The examples on this page will use the universal "curl" command to execute the API calls. For examples of implementing the curl calls in other languages, see: Curl in PHP, Curl in Ruby, or Curl in C#

Before you get started, please authenticate with the API to obtain an access token.

Fetching Orders with a Timed Job

With this approach, your app pulls orders from Reverb on a timer. You can set up a cron job to do this nightly, or run a manual script to do so.

First, we'll fetch the orders for a given date range:

curl -XGET -H "X-Auth-Token: [yourtoken]" https://reverb.com/api/my/orders/selling/all?created_start_date=2015-01-01T12:00-00:00&created_end_date=2015-01-02T12:00-00:00

Try an interactive call to the order endpoint

The response will contain a list of order objects, which you can parse to update orders in your system:

Getting Notified of Order Changes via Webhooks

With this approach, your app registers a webhook endpoint, and Reverb will POST to your endpoint when an order is created. You can also subscribe to the "listings/update" event for when listings are updated (inventory changes).

Step1: Register your webhook

curl -XPOST https://reverb.com/api/webhooks/registrations --data '{"url": "http://yoursite.com/yourendpoint", "topic": "orders/create"}' -H "X-Auth-Token: [yourtoken]" -H "Content-Type: application/hal+json" -H "Accept: application/hal+json"

Step2: Build your endpoint

You will need to produce an http endpoint that responds to POST on the URL you registered above. This endpoint will receive as params a hash representing an Order, which is identical to the ones in the response shown in section above.