Ghost Analytics node.js client
Installation
npm install ghost-analytics-client --save
Documentation
Documentation is not yet available.
API Overview
Every resource is accessed via your ghost-analytics-client
instance:
const GhostAnalytics = publicKey: ' your public key ' secretKey: ' your secret key ' ;// GhostAnalytics.{ RESOURCE_NAME }.{ METHOD_NAME }
Every resource method returns a promise (bluebird):
GhostAnalyticscustomer;
Notes
Where you see params
it is a plain JavaScript object, e.g. { email: 'foo@example.com' }
For requests that return a single
item, the item will be contained inside of the doc
property in the response body.
For requests that return multiple
items, the items will be contained inside of the docs
property in the response body.
For requests that delete an item, the response body will contain { success: true }
.
Account
Endpoint | Description |
---|---|
[GET /api/v1/accounts/{accountId}] | Get an account |
GET /api/v1/accounts/{accountId}
Returns an account object.
Example Request
GhostAnalyticsaccount;
Example Response
Charge
Endpoint | Description |
---|---|
[POST /api/v1/charges] | Create a charge |
POST /api/v1/charges
Creates and returns a charge object.
Example Request
GhostAnalyticscharge;
Example Response
CustomerCard
Endpoint | Description |
---|---|
[GET /api/v1/customers/{customerId}/cards/{cardId}] | Get a customer card |
[POST /api/v1/customers//{customerId}] | Create a customer card |
[DELETE /api/v1/customers/{customerId}/cards/{cardId}] | Delete a customer card |
GET /api/v1/customers/{customerId}/cards/{cardId}
Returns a customer card object.
Example Request
GhostAnalyticscustomerCard;
Example Response
POST /api/v1/customers/{customerId}/cards
Creates and returns a customer card object.
Example Request
GhostAnalyticscustomerCard;
Example Response
DELETE /api/v1/customers/{customerId}/cards/{cardId}
Deletes a customer card object.
Example Request
GhostAnalyticscustomerCard;
Example Response
Customer
Endpoint | Description |
---|---|
[GET /api/v1/customers/{customerId}] | Get a customer |
[POST /api/v1/customers] | Create a customer |
[PUT /api/v1/customers/{customerId}] | Update a customer |
[DELETE /api/v1/customers/{customerId}] | Delete a customer |
GET /api/v1/customers/{customerId}
Returns a customer object.
Example Request
GhostAnalyticscustomer;
Example Response
POST /api/v1/customers
Creates and returns a customer object.
Example Request
GhostAnalyticscustomer;
Example Response
PUT /api/v1/customers/{customerId}
Updates and returns a customer object.
Example Request
GhostAnalyticscustomer;
Example Response
DELETE /api/v1/customers/{customerId}
Deletes a customer object.
Example Request
GhostAnalyticscustomer;
Example Response
IdentityEvent
Endpoint | Description |
---|---|
[POST /api/v1/identites/{identityId}/events] | Create an identity event |
POST /api/v1/identites/{identityId}/events
Creates and returns an identity event object.
Example Request
GhostAnalyticsidentityEvent;
Example Response
Order
Endpoint | Description |
---|---|
[GET /api/v1/orders/{orderId}] | Get an order |
[GET /api/v1/orders] | Fetch orders |
[POST /api/v1/orders] | Create an order |
[DELETE /api/v1/orders/{orderId}] | Delete an order |
GET /api/v1/orders/{orderId}
Returns an order object.
Example Request
GhostAnalyticsorder;
Example Response
GET /api/v1/orders
Fetches order objects based on input parameters.
Example Request
GhostAnalyticsorder;
Example Response
POST /api/v1/orders
Creates and returns an order object.
Example Request
GhostAnalyticsorder;
Example Response
DELETE /api/v1/orders/{orderId}
Deletes an order object.
Example Request
GhostAnalyticsorder;
Example Response
Errors
All error responses are in the following format, delivered with the corresponding status code: