up

API


Introduction

This page documents the REST API for Gaglers. Response format is JSON. All APIs are served over HTTPS only.

API endpoint

https://developer.gaglers.com/api/v1/

Authentication

We use API key based authentication. The key is passed in the header. For example, curl -i -H ”Authorization: apikey {username}:{api_key}" https://developer.gaglers.com/api/v1/user/1/ You can get the API key from the profile tab in the dashboard.

Response Codes

Success:            200
Created: 201
Failure: 500
Access Denied: 403
Validation Failure: 400

Create Agent

POST /user

Registers a new agent with Gaglers

Return Value

A successful POST call with return 201 with the "location" header set with the URI of the resource that was created.

Parameters

username A unique name for a user. Tip: you could add <username>_<domainname> to make it unique. For example "sid_ecomarket.com"

password

A default password for the user. This can be changed after creation by logging into the dashboard

nickname

The name displayed in the chat widget. This is a required parameter.

gmail_id

Instead of the "username" and "password" parameter, you could just provide a gmail_id instead.

Note: Either the "username" and "password" or the "gmail_id" parameter must be provided.

avatar_url (optional)

URL to the avatar image for the Chat. The image will be hosted on gaglers and it will not be a hotlink

email (optional)

EMail id for any offline messages


Show Agent

GET /user/{user-id}

Retrieves the agent specified by the user-id

Return Value

A successful GET call will return 200. The content is a JSON with the agent's details


Examples for using Agent Object

Register an agent with Gmail id

#curl -i -H ”Authorization: apikey foouser:1eee4a163f9ff14b3277cb5584a05e71e387252b” -H "Content-Type: application/json" -X POST --data '{"gmail_id":"augustus.franklin@gmail.com", "nickname": "Augustus","avatar_url":"https://twimg0-a.akamaihd.net/profile_images/1463564988/profile.jpg" }' "https://developer.gaglers.com/api/v1/user/"
HTTP/1.1 201 CREATED
                    

Location: http://developer.gaglers.com/api/v1/user/573/

Register an agent with username and password

#curl -i -H ”Authorization: apikey foouser:1eee4a163f9ff14b3277cb5584a05e71e387252b”-H "Content-Type: application/json" -X POST --data '{"username": "doctor1_mywebsite.com", "password": "temppassword", "nickname": "Great Clinic", "avatar_url": "https://twimg0-a.akamaihd.net/profile_images/1463564988/profile.jpg" }' "https://developer.gaglers.com/api/v1/user/"
HTTP/1.1 201 CREATED
                    

Location: http://developer.gaglers.com/api/v1/user/3447/

Show Agent

#curl -i -H ”Authorization: apikey foouser:1eee4a163f9ff14b3277cb5584a05e71e387252b”https://developer.gaglers.com/api/v1/user/1/
HTTP/1.1 200 OK
                    

{"nickname": "Gaglers", "resource_uri": "/api/v1/user/1/", "userid": 1, "username": "Gaglers_Twitter"}


Create Chat Widget

POST /topic

Creates a chat widget to be used on your website

Return Value

A successful POST call with return 201 with the "location" header set with the URI of the resource that was created.

Parameters

site_url

The website for which the chat widget is created for. This website must be already registered with Gaglers. This is a required parameter.

name

A unique name for the chat widget. The name must only be unique within the registered website. This is a required parameter.

operators

A list of user ids of the agents for this chat widget. A chat widget must have at least one agent

Important Note: When a chat widget is created the agent will immediately get buddy requests to accept in their Gtalk clients. Agents created without a gmail id (with only username/password), the buddy requests will be automatically accepted.


Show Chat Widget

GET /topic/{topic-id}

Gets details about a particular shop-id

Return Value

A successful GET call will return 200.The content is a JSON with the chat widget's properties


Examples to use the Chat Widget Object

Register a chat widget

#curl -i -H ”Authorization: apikey foouser:1eee4a163f9ff14b3277cb5584a05e71e387252b” -H "Content-Type: application/json" -X POST --data '{"site_url": "http://www.mywebsite.com","name": "My Great Clinic","operators":["3447"] }' "https://developer.gaglers.com/api/v1/topic/"
HTTP/1.1 201 CREATED
                    

Location: http://developer.gaglers.com/api/v1/topic/36/

Get Chat Widget Information

#curl -i -H ”Authorization: apikey foouser:1eee4a163f9ff14b3277cb5584a05e71e387252b” https://developer.gaglers.com/api/v1/topic/1/
HTTP/1.1 200 OK
                    

{"name": "HindiPoems", "onlineoperators": [], "operators": ["573"], "resource_uri": "/api/v1/topic/1/", "site_url": "http://www.prayogshala.com", "topicid": 1}


Marketplace Integration Flow

The following is the order of the integration for every chat widget in the marketplace.

1. Register the agent object with Gaglers

2. Register the chat widget object with the agent registered in the previous step

3. Embed the customised code for the chat widget in the HTML page of the shop and of every product sold in the shop