Skip to content

Instantly share code, notes, and snippets.

@rushi

rushi/XolaAPI.md Secret

Last active September 27, 2016 15:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rushi/1905603396523a5519f9 to your computer and use it in GitHub Desktop.
Save rushi/1905603396523a5519f9 to your computer and use it in GitHub Desktop.
Working with the Xola API

Xola API documentation

Create a new account

New accounts are created via a POST request to the users API end point. The email address should be a valid address that will receive a confirmation email.

curl -H "Content-type: application/json" -X POST https://dev.xola.com/api/users -d '{
	"name" : "John Doe",
	"email" : "john.doe@gmail.com",
	"password" : "password123", 
	"roles" : ["ROLE_DEVELOPER"]
}'

IMPORTANT: Once the account is created, click on the activation link in the email to proceed ahead

Get your account information

Grab your user account ID and check up on your roles. Make note of your user id, as that will be used to get your API Key

curl -H "Content-type: application/json" https://dev.xola.com/api/users/me -u "john.doe@gmail.com:password123"

Get your API Key

curl -H "Content-type: application/json" https://dev.xola.com/api/users/<my_user_id>/apiKey -u "john.doe@gmail.com:password123"

All future requests don't need username password. You can use the API Key, for example - getting your user info

curl -H 'X-API-KEY: MYRANDOMLYGENERATEDAPIKEYGOESHERE' -H 'Content-type: application/json' https://dev.xola.com/api/users/me

Fetch Experiences

Fetching all experiences requires an authenticated user

curl -H 'X-API-KEY: MYRANDOMLYGENERATEDAPIKEYGOESHERE' -H 'Content-type: application/json' https://dev.xola.com/api/experiences

No auth required for fetching information about a specific experience

curl -H 'Content-type: application/json' https://dev.xola.com/api/experiences/4f358f70536e86b149000000

Creating an Order

To create an order you can use the POST /api/orders endpoint.

curl -X POST https://dev.xola.com/api/orders -H 'X-API-KEY: MYRANDOMLYGENERATEDAPIKEYGOESHERE' -H 'Content-type: application/json' -d '{
    "source" : "office",
    "status" : 100,
    "experienceName" : "Hiking in California Wine Country",
    "quantity" : 2,
    "experience" : { 
        "id" : "4f358f70536e86b149000000"
    },  
    "arrival" : "2013-09-22",
    "price" : 2300,
    "priceType" : "person",
    "guestType" : "normal",
    "customerName" : "Josh Lyman",
    "customerEmail" : "josh.lyman@mailinator.com",
    "currency" : "USD",
    "payment" : { 
        "method" : "cash",
        "comment" : "This guy loves hiking, is a repeat customer"
    }   
}'

Refer to the detailed documentation at https://dev.xola.com/api/doc to prepare & create orders.

Useful tips & tools

Postman Rest Client - A Google Chrome extension to help you create API requests.

Firefox REST Client - A Firefox add-on to help you create API requests

Using Curl

Curl request to send a JSON request through an input file

curl -X POST -d @input.json https://dev.xola.com/api/users

View Response headers including the status code

curl -i https://dev.xola.com/api/experiences

Curlish - A nice wrapper over Curl to ease some tedious tasks

More curl tips - https://httpkit.com/resources/HTTP-from-the-Command-Line/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment