Sarshomar | Focus on your question. Do not be too concerned about how to ask or analyze. Sarshomar

Getting started

Sarshomars API exposes the entire Sarshomar infrastructure via a standardized programmatic interface. Using Sarshomars API, you can do just about anything you can do on Sarshomar.com.

The Sarshomar API is a RESTful API based on HTTPS requests and JSON responses. If you are registered with Sarshomar, you can obtain your API key from My Account page, found here: Go to My account.

Endpoints

The API is accessed by making HTTPS requests to a specific version endpoint URL, in which GET, POST, PUT and DELETE methods dictate how your interact with the information available. Every endpoint is accessed only via the SSL-enabled HTTPS (port 443) protocol.

Everything (methods, parameters, etc.) is fixed to a version number, and every call must contain one. The latest version is Version 1.

The stable HTTPS endpoint for the latest version is:

https://sarshomar.com/api/v1/

HTTP response codes

The status of a response can be determined from the HTTP status code.

Code Status Description
200 OK request successful
304 Not Modified
400 Bad Request request was invalid
401 Unauthorized user does not have permission
403 Forbidden request not authenticated
429 Too many requests client is rate limited
405 Method Not Allowed incorrect HTTP method provided
415 Unsupported Media Type response is not valid JSON

Get temporary login key

Get a temporary login key from Sarshomar


get/token/login

ID
Variable
Description
Priority
Example
guest Guest token
Optional
 

Header

Accept:application/json Authorization:$2y$07$fRI1wcT6B6JxCaowePUliuNgkNbswDCbmKcnnDWynfEpxUjfRzVry

Request

{ "guest": "null|[guest token]" }

cURL

curl

Request guest token

Request a guest token from Sarshomar


post/token/guest

Header

Accept:application/json Authorization:$2y$07$fRI1wcT6B6JxCaowePUliuNgkNbswDCbmKcnnDWynfEpxUjfRzVry

cURL

curl

Response

{ "status": 1, "title": null, "msg": { "callback": { "token": "$2y$07$fRI1wcT6B6JxCaowePUliuNgkNbswDCbmKcnnDWynfEpxUjfRzVry" } } }

Add poll

Add poll via Sarshomar API


post/poll

ID
Variable
Description
Priority
Example
title
string
Set the poll title
Mandatory
"How is the weather like?"
survey
code
Survey code
Optional
"3r"
language
fa
Set the language of your choice
Optional
"en"
summary
string
Write the summary of your poll
Optional
"The weather is an important factor for travelers of your city."
description
string
Describe your poll
Optional
"please selectan option that describes the weather in your city."
file
code
Upload a file like an image that shows the weather in your city.
Optional
"3tf59"
tree
object
The tree of the question specifies the parent and answers connected to the poll
Optional
Go to table
branding
object
If the poll is being created by a brand or company, they can fill in the required information to show their brand identity.
Optional
Go to table
answers
array of objects
The answer to the poll or question is specified by this variable
Mandatory
Go to table
options
object
Set different options for your poll
optional
Go to table
hide_result
BOOL
whether to hide the results from public or not is set by this variable
Optional
true
schedule
object
Schedule a poll to be published at a certain time and date in the future
optional
Go to table
articles
array
Select an article to connect it to your poll or question
Mandatory
["3rx","cv54"]
tags
array
select the tags of the question
Mandatory
["sample tag","sample tag"]
cat
code
Set the category of the poll or question.
Mandatory
"x46"
from
object
Select the target audience of the poll
optional
Go to table

Poll Tree

ID
Variable
Description
Priority
Example
parent
code
Set a parent for the poll.
Mandatory
"246js"
answers
BOOL
Select the answers of the parent poll.
Mandatory
true

Poll Branding

ID
Variable
Description
Priority
Example
title
string
Name of the brand
Mandatory
"Sarshomar, Ask and Answer anywhere"
url
string
The URL of the brand's company
Optional
"https://sarshomar.com"

Poll Answers

ID
Variable
Description
Priority
Example
title
string
Set a title for the answer.
Optional
"Weather conditions"
type
select
select the type of the answer.
Mandatory
"select"
file
url
If your answers has a file like an image, specify it here.
Mandatory
"https://sarshomar.com/static/images/svg/general/logo.svg"
select
object
Set answers options
Mandatory
Go to table

Poll Select

ID
Variable
Description
Priority
Example
is_true
BOOL
Set the true answer of the poll if it has one.
Optional
true
score
object
If the answers have score specify them by this variable.
Mandatory
Go to table

Poll Score

ID
Variable
Description
Priority
Example
group
string
Specify the group that your poll belongs to.
Optional
"Math and Physics"
value
int
An integer showing the value of score
Optional
12

Poll Options

ID
Variable
Description
Priority
Example
time
int
Set the time for the poll
Optional
12
multi
object
Set minimum and maximum time for the poll
Mandatory
Go to table
random_sort
BOOL
To do a random sort of options set this variable
Optional
true
ordering
BOOL
Set the order of options by this variable
Optional
true

Poll multi

ID
Variable
Description
Priority
Example
min
int
Set the minimum time for the poll.
Mandatory
10
max
int
Set the maximum time for the poll.
Mandatory
25

Poll Schedule

ID
Variable
Description
Priority
Example
start
date_time
Set the date and time that the poll should start.
Optional
2017-10-03 10:53:14
end
date_time
Set the date and time that the poll should end.
Optional
2018-11-11 09:13:26

Poll From

ID
Variable
Description
Priority
Example
count
int
From how many person the poll should be asked.
Optional
3500
gender
array
Select the gender that can answer the poll. You can set one or more items or leave it null.
["male", "female"]
Optional
["male"]
marrital
array
Set the marrital status of the people who can answer the poll. You can set one or more items or leave it null.
["single", "married"]
Optional
["single"]
graduation
array
Set the graduation status of the people who can answer the poll. You can set one or more items or leave it null.
["illiterate", "undergraduate", "graduate"]
Optional
["graduate"]
degree
array
Set the university or college degree status of the people who can answer the poll. You can set one or more items or leave it null.
["under_diploma", "diploma", "2_year_college", "bachelor", "master", "phd"]
Optional
["master"]
range
array
Set the age range of the people who can answer the poll. You can set one or more items or leave it null.
["-13", "diploma", "14-17", "18-24", "25-30", "31-44", "45-59", "60+"]
Optional
["18-24"]
employmentstatus
array
Set the job status of the people who can answer the poll. You can set one or more items or leave it null.
["employee", "unemployed", "retired"]
Optional
["unemployed"]
housestatus
array
Set the housing status of the people who can answer the poll. You can set one or more items or leave it null.
["owner", "tenant", "homeless"]
Optional
["tenant"]

Header

Accept:application/json Authorization:$2y$07$fRI1wcT6B6JxCaowePUliuNgkNbswDCbmKcnnDWynfEpxUjfRzVry

Request

{ "title": "string", "survey": "null|code", "language": "fa|en|ar|null for set as default", "summary": "string|null", "description": "string|null", "file": "code", "tree": { "parent": "code", "answers": "skipped|true|[1,5,7]" }, "branding": { "title": "string", "url": "string|null" }, "answers": [{ "title": "null|string", "type": "select", "file": "code", "select": { "is_true": "true|false", "score": { "group": "null|string", "value": "null|int" } } }], "options": { "time": "int|null", "multi" : { "min" : 3, "max" : 10, }, "random_sort": "true|false", "hide_result": "true|false", "ordering": "true|false" }, "schedule": { "start": "null|date_time", "end": "null|date_time" }, "articles": ["code", "code"], "tags": ["movie","film","sample tag"], "cat": "code", "from": { "count": "ultimate|int|null", "gender": [ "male", "female", "null" ], "marrital": [ "single", "married", "null" ], "graduation": [ "illiterate", "undergraduate", "graduate" ], "degree": [ "under_diploma", "diploma", "2_year_college", "bachelor", "master", "phd" ], "range": [ "-13", "14-17", "18-24", "25-30", "31-44", "45-59", "60+" ], "employmentstatus": [ "employee", "unemployed", "retired" ], "housestatus": [ "owner", "tenant", "homeless" ] } }

cURL

curl - X POST - H "Accept: application/json" - H "Authorization: $2y$07$fRI1wcT6B6JxCaowePUliuNgkNbswDCbmKcnnDWynfEpxUjfRzVry" - H "Content-Type: application/json" - H "Cache-Control: no-cache" - H "Postman-Token: 3290ba65-4654-7450-219e-ae67b95cc82d"

Response

{ "status": 1, "title": "Poll Successfully added", "msg": { "callback": { "id": "3y" } }, "result": { "id": "3y" } }

Get poll

Get poll via Sarshomar API


get/poll

ID
Variable
Description
Priority
Example
id
int
Poll ID
Mandatory
"3rs15"
type
string
Poll Type can be one of
["ask"] Get questions from type ask
["random"] Get random questions
["ask", "random"] Get random questions from type ask
null Get any type of questions
Optional
["ask"]

Header

Accept:application/json Authorization:$2y$07$fRI1wcT6B6JxCaowePUliuNgkNbswDCbmKcnnDWynfEpxUjfRzVry

Request

{ "id": "[poll id]", "type" : "ask|random|null" }

cURL

curl - X GET - H "Accept: application/json" - H "Authorization: $2y$07$fRI1wcT6B6JxCaowePUliuNgkNbswDCbmKcnnDWynfEpxUjfRzVry" - H "Cache-Control: no-cache" - H "Postman-Token: b518c969-a4df-b3b4-14a7-a07a3d29dc02" "http://sarshomar.dev/fa/api/v1/poll?id=3r"

Response

{ "status": 1, "title": null, "msg": { "callback": { "id": "3y", "language": "fa", "title": "روز معلم مصادف با چه روزی است؟", "slug": "roz-maalm-msadf-ba-che-rozy-ast", "url": "$/3y/روز_معلم_مصادف_با_چه_روزی_است؟", "type": "poll", "comment": "open", "meta": { "desc": "", "opt": [ { "key": "opt_1", "txt": "شهادت شهید مطهری", "type": "text" }, { "key": "opt_2", "txt": "شهادت شهید بهشتی", "type": "text" }, { "key": "opt_3", "txt": "شهادت شهید رجایی", "type": "text" } ], "comment": true }, "status": "deleted", "user_id": "H", "sarshomar": true, "privacy": "public", "result": { "count_answered": { "valid": 39, "invalid": 0, "sum": 39 }, "result": { "1": { "text": "fff", "key": "1", "type": null, "valid": 0, "invalid": 0, "sum": 0 }, "2": { "text": "exded", "key": "2", "type": null, "valid": 14, "invalid": 0, "sum": 14 } } } } } }

Search poll via Sarshomar API


get/poll/search

ID
Variable
Description
Priority
Example
search
string
search
optional
"Weather conditions"
my_poll
BOOL
...
optional
true
language
fa
Set the poll language
optional
"en"
from
int
From...
Mandatory
0
to
int
To...
Mandatory
10

Header

Accept:application/json Authorization:$2y$07$fRI1wcT6B6JxCaowePUliuNgkNbswDCbmKcnnDWynfEpxUjfRzVry

Request

{ "search": "sdghl|null to get last", "in": "sarshomar|me|other", "in": ["sarshomar","me","other"], "in": "all", "status" : "publish|draft|trash", "status" : ["publish","draft","trash"], "language": "fa|en|ar|null", "language": ["fa","en","ar"], "language": "fa", "from" : 0, "to" : 10, }

cURL

curl

Response

{ "status": 1, "title": null, "msg": { "callback": [ { "is_answered": true, "my_fav": true, "id": "3y", "title": "sf", "slug": "sf", "url": "$/3y", "type": "poll", "status": "publish", "user_id": "6", "sarshomar": true, "privacy": "public" }, { "my_like": true, "my_fav": true, "id": "3x", "title": "sf", "slug": "sf", "url": "$/3x", "type": "poll", "status": "publish", "user_id": "6", "sarshomar": true, "privacy": "public" } ] } }

Submit a poll answer

Submit an answer via Sarshomar API


post/poll/answer

ID
Variable
Description
Priority
Example
id
string
Poll ID
Mandatory
"434sf"
skipped
BOOL
Is the poll skipped
Optional
true
answer
array of objects
Answers to the poll
["True", "False", "int", "string", "url"]
Optional
true

Header

Accept:application/json Authorization:$2y$07$fRI1wcT6B6JxCaowePUliuNgkNbswDCbmKcnnDWynfEpxUjfRzVry

Request

{ "id": "[poll id]", "skip": true, "answer": { "1": true, "2": true } }

cURL

curl

Response

{ }

Favorite a question

Favorite a question via Sarshomar API


post/poll/fav

ID
Variable
Description
Priority
Example
id
string
Poll ID
Mandatory
"54fa8"
fav
BOOL
Whether to favorite the poll or not
optional
true

Header

Accept:application/json Authorization:$2y$07$fRI1wcT6B6JxCaowePUliuNgkNbswDCbmKcnnDWynfEpxUjfRzVry

Request

{ "id": "[poll id]", "fav": "true|false|[leave it null to toggle favorites]" }

cURL

curl

Response

{ "status": 1, "title": null, "msg": [ "callback" ], "messages": { "true": [ { "title": "Favourites set", "element": false, "group": "public" } ] } }

like a question

like a question via Sarshomar API


post/poll/like

ID
Variable
Description
Priority
Example
id
int
Poll ID
Mandatory
"3fxr45"
like
BOOL
Whether to like the poll or not
optional
true

Header

Accept:application/json Authorization:$2y$07$fRI1wcT6B6JxCaowePUliuNgkNbswDCbmKcnnDWynfEpxUjfRzVry

Request

{ "id": "[poll id]", "like": "true|false|[leave it null to toggle like]" }

cURL

curl

Response

{ "status": 1, "title": null, "msg": [ "callback" ], "messages": { "true": [ { "title": "Like set", "element": false, "group": "public" } ] } }

calculate price of a question

Calculate price of a question via Sarshomar API


post/poll/price

ID
Variable
Description
Priority
Example
id
int
Poll ID
optional
"3rf"
poll
object
Poll...
Optional
Go to table
survey
object
Survey options
Optional
Go to table
member
int
member...
Mandatory
5488
branding
BOOL
Whether is it for a brand or not
Mandatory
true
Filters
object
Filter options
Optional
Go to table

Calculate Price Poll

ID
Variable
Description
Priority
Example
nofity
BOOL
Nofity...
Optional
true

Calculate Price of Survey

ID
Variable
Description
Priority
Example
child
int
child...
Mandatory
5489
nofity
int
nofity...
Mandatory
244

Calculate Price Filters

ID
Variable
Description
Priority
Example
gender
BOOL
Has gender filter
Mandatory
true
marrital
BOOL
Has marrital filter
Mandatory
true
internetusage
BOOL
Has internet usage filter
Mandatory
true
graduation
BOOL
Has graduation filter
Mandatory
true
degree
BOOL
Has degree filter
Mandatory
true
range
BOOL
Has range filter
Mandatory
true
employmentstatus
BOOL
Has employment filter
Mandatory
true
housestatus
BOOL
Has housing filter
Mandatory
true

Header

Accept:application/json Authorization:$2y$07$fRI1wcT6B6JxCaowePUliuNgkNbswDCbmKcnnDWynfEpxUjfRzVry

Request

{ "id": "[poll or survey id]|null", "poll": { "nofity": true }, "survey": { "child": 20, "nofity": 1 }, "member": "int", "branding": true, "filters": { "gender": true, "marrital": true, "internetusage": true, "graduation": true, "degree": true, "range": true, "employmentstatus": true, "housestatus": true } }

cURL

curl

Response

{ "status": 1, "title": null, "msg": [ "callback" ], "messages": { "true": [ { "title": "Like set", "element": false, "group": "public" } ] } }

Add profile

Add profile via Sarshomar API


post/profile

ID
Variable
Description
Priority
Example
language
string
The user language
Optional
"fa"
unit
string
The user unit
Optional
"toman"
gender
string
The user gender
Optional
"male"
marrital
string
The user marrital
Optional
"married"
graduation
string
The user graduation
Optional
"illiterate"
degree
string
The user degree
Optional
"under diploma"
range
string
The user range
Optional
"25-30"
employmentstatus
string
The user employmentstatus
Optional
"employee"
housestatus
string
The user housestatus
Optional
"owner"

Header

Accept:application/json Authorization:$2y$07$fRI1wcT6B6JxCaowePUliuNgkNbswDCbmKcnnDWynfEpxUjfRzVry

Request

{ "language": "fa", "unit": "toman", "gender": "male", "marrital": "married", "graduation": "illiterate", "degree": "under diploma", "range": "25-30", "employmentstatus": "employee", "housestatus": "owner" }

cURL

curl - X PATCH - H "Accept: application/json" - H "Authorization: $2y$07$fRI1wcT6B6JxCaowePUliuNgkNbswDCbmKcnnDWynfEpxUjfRzVry" - H "Content-Type: application/json" - H "Cache-Control: no-cache" - H "Postman-Token: 3290ba65-4654-7450-219e-ae67b95cc82d"

Response

{ "status": 1, "title": "The profile data was change", "msg": [ "callback" ], "messages": { "true": [ { "title": "User language changed", "element": "language", "group": "arguments" }, { "title": "User unit changed", "element": "unit", "group": "arguments" }, { "title": "Sarshomar's gift belongs to you for completing your profile", "element": false, "group": "public" } ] } }

Billing

Billing via Sarshomar API


post/billing/balance

ID
Variable
Description
Priority
Example

Header

Accept:application/json Authorization:$2y$07$fRI1wcT6B6JxCaowePUliuNgkNbswDCbmKcnnDWynfEpxUjfRzVry

Request

{}

cURL

cURL

Response

{ "status": 1, "title": null, "msg": { "callback": { "gift": 200, "real": 100, "prize": 300, "transfer": 400, "sum": 1000 } } }
Go to top
We are inestimable

Inspection and Answer

Then if we were inestimable, Signup!

Try Before Register