Skip to content

Instantly share code, notes, and snippets.

@gtarun
Created June 19, 2017 12:59
Show Gist options
  • Save gtarun/69954e7765cab17cd295fc74af541131 to your computer and use it in GitHub Desktop.
Save gtarun/69954e7765cab17cd295fc74af541131 to your computer and use it in GitHub Desktop.
og-public-api
swagger: "2.0"
info:
version: v1
title: Outgrow Public API
host: api.outgrow.co
basePath: /api/v1
schemes:
- https
- http
consumes:
- application/json
produces:
- application/json
security:
- UserSecurity: []
paths:
# For Calcualtors
/calculator:
get:
tags:
- Calculators
summary: List all 'Calculator/Quiz in your outgrow account'
description: Returns 'Calculator/Quiz' of particular company
operationId: getCalculator
produces:
- application/json
parameters:
- $ref: "#/parameters/CalculatorStatus"
- $ref: "#/parameters/Limit"
- $ref: "#/parameters/CalculatorType"
- $ref: "#/parameters/CreatedFrom"
- $ref: "#/parameters/CreatedTo"
- $ref: "#/parameters/SortBy"
responses:
200:
description: Success
schema:
$ref: "#/definitions/CalculatorListBody"
default:
description: Error
schema:
$ref: "#/definitions/CalculatorErrorResponse"
# For Leads
/leads/add:
post:
tags:
- Leads
summary: Creates a Lead
description: Adds a new lead to the calculator.
parameters:
- name: lead
in: body
required: true
schema:
$ref: "#/definitions/LeadPostBody"
responses:
200:
description: Leads succesfully created.
schema:
$ref: "#/definitions/LeadCreatedBody"
400:
description: Leads couldn't have been created.
schema:
$ref: "#/definitions/ErrorResponse"
/leads/{calculator}:
get:
tags:
- Leads
summary: Get leads data
description: Returns 'Leads' of particular Calculator/Quiz
operationId: getLeads
produces:
- application/json
parameters:
- name: calculator
in: path
required: true
description: Live Calculator Id
type: string
- name: limit
in: query
description: 'Number of Leads to return. For all: -1 or without Limit key all leads comes'
required: false
type: integer
responses:
200:
description: Success
schema:
$ref: "#/definitions/LeadListBody"
default:
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
# For Fields
/fields/{calculator}:
get:
tags:
- Fields
summary: Gets Calculator/Quiz Fields
description: Gets the Configuration of the Calculator
produces:
- application/json
parameters:
- name: calculator
in: path
required: true
description: Live Calculator Id
type: string
- name: type
in: query
required: true
type: string
default: leads
enum:
- leads
- questions
- results
description: >
Type Based:
* lead: Gets LeadForm Field of Calculator
responses:
200:
description: Success
schema:
$ref: "#/definitions/FieldListBody"
default:
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
# For Analytics
/analytics/{calculators}:
get:
tags:
- Analytics
summary: Gets Calculator/Quiz Analytics
description: Gets all the Analytics of the calculator based on Live Calculator Id
produces:
- application/json
parameters:
- name: calculators
in: path
required: true
description: Live Calculator Id
type: string
- name: start_date
in: query
description: |
Filter based on analytics of calculator start date
format: YYYY-MM-DD
required: false
type: string
format: date
- name: end_date
in: query
description: |
Filter based on analytics of calculator start date
format: YYYY-MM-DD
required: false
type: string
format: date
responses:
200:
description: Success
schema:
$ref: "#/definitions/AnalyticsListBody"
default:
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
securityDefinitions:
UserSecurity:
description: Your API Key
type: apiKey
name: API-Key
in: header
definitions:
# Common Error Response
ErrorResponse:
required:
- response
properties:
response:
type: array
items:
$ref: "#/definitions/ErrorResponse_response"
ErrorResponse_response:
required:
- code
- message
properties:
code:
type: integer
message:
type: string
description:
type: string
# Calculator Response
CalculatorListBody:
required:
- calculators
properties:
calculators:
type: array
items:
$ref: "#/definitions/Calculator"
Calculator:
required:
- createdAt
- id
- name
- state
- type
properties:
id:
type: string
type:
type: string
state:
type: string
name:
type: string
createdAt:
type: string
updatedAt:
type: string
meta_data:
$ref: "#/definitions/Calculator_meta_data"
CalculatorErrorResponse:
required:
- response
properties:
response:
type: object
items:
$ref: "#/definitions/CalculatorErrorResponse_response"
Calculator_meta_data:
properties:
title:
type: string
favicon:
type: string
ga_tracking_id:
type: string
url:
type: string
description:
type: string
CalculatorErrorResponse_response:
required:
- message
properties:
code:
type: integer
message:
type: string
description:
type: string
# Lead Response
LeadListBody:
required:
- calculators
properties:
calculators:
type: array
items:
$ref: "#/definitions/Lead"
Lead:
required:
- id
- calc_name
- created_at
properties:
id:
type: string
calc_name:
type: string
created_at:
type: string
user_info:
type: object
location:
type: object
results:
type: array
items:
type: string
questions:
type: array
items:
type: string
total_question:
type: number
answered:
type: number
LeadPostBody:
required:
- calculator
properties:
calculator:
type: string
description: Live Calculator Id
example: 5892d26dcbff7e0b1c34bf65
leads:
type: array
description: Put all required Fields
items:
type: object
properties:
key:
type: string
description: Fields Key name
example: email
value:
type: string
example: admin@admin.com
questions:
type: array
description: Put Your Calculator Questions
items:
type: object
properties:
key:
type: string
description: Questions Field key name
example: what_is_your_calculator_name?
value:
type: [string, number, boolean]
description: |
Set this property for the value of options
example: ['test', 1, true]
answer:
type: string
description: |
Set this property when ever options has some text(don't use for slider)
example: less than 1
LeadCreatedBody:
required:
- success
properties:
success:
type: string
leads:
type: array
items:
type: object
questions:
type: array
items:
type: object
message:
type: string
# Field Response
FieldListBody:
required:
- response
properties:
response:
type: object
success:
type: boolean
fields:
type: array
items:
required:
- key
properties:
id:
type: number
key:
type: string
name:
type: string
type:
type: string
# Analytics Response
AnalyticsListBody:
required:
- data
- success
properties:
data:
type: object
items:
properties:
unique_visitors:
type: number
visitors:
type: number
time_on_page:
type: string
conversions:
type: number
conversion_rate:
type: string
avg_response:
type: string
engagements:
type: string
calc_starts:
type: string
deviceCategory:
type: array
browser:
type: array
country:
type: array
socialNetwork:
type: array
success:
type: boolean
parameters:
CalculatorStatus:
name: status
in: query
description: Filter Calculator/Quiz based on Status
required: false
type: string
default: Both
enum:
- Both
- Live
- Draft
Limit:
name: limit
in: query
description: Number of Calculator/Quiz to return
required: false
type: integer
CalculatorType:
name: type
in: query
description: Filter based on type
required: false
type: string
default: Both
enum:
- Both
- Calculator
- Quiz
CreatedFrom:
name: created_from
in: query
description: |
Filter based on created from date
format: YYYY-MM-DD
required: false
type: string
format: date
CreatedTo:
name: created_to
in: query
description: |
Filter based on created from date
format: YYYY-MM-DD
required: false
type: string
format: date
SortBy:
name: sort
in: query
description: |
Sort
An item can be sort of different type:
type | description
---- | -----------
alpha_asc: | Sort Calcualtor/Quiz by Ascending Name
alpha_desc: | Sort Calcualtor/Quiz by Descending Name
created_date_asc: | Sort Calcualtor/Quiz by Ascending Created Date
created_date_desc: | Sort Calcualtor/Quiz by Descending Created Date
updated_date_desc: | Sort Calcualtor/Quiz by Descending Updated Date
updated_date_asc: | Sort Calcualtor/Quiz by Descending Updated Date
required: false
type: string
default: alpha_asc
enum:
- alpha_asc
- alpha_desc
- created_date_asc
- created_date_desc
- updated_date_desc
- updated_date_asc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment