UpStudy API Documentation
Introduction
UpStudy API is a powerful mathematical problem-solving tool that supports multiple languages, offering quick solutions and detailed step-by-step breakdowns. It caters to educators, researchers, and developers."
*We are currently offering a limited-time free trial.
Quick Start
1. Register and Create an API Key
- Visit the UpStudy API Portal and sign up for an account.
- After logging in, navigate to the Settings page.
- Click on "New API Key" to generate your unique API key.
- Store your API key securely - you'll need it for all API requests.
2. Make Your First API Request
2.1 Prerequisites
Ensure you have the following:
- An API key
- A development environment (e.g., Go, Python, JavaScript)
2.2 Using HTTP Requests
curl example:
curl -X 'POST' \
'https://api.cameramath.com/v1/single-answer' \
-H 'accept: application/json' \
-H 'Authorization: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"input": "x^{2}-3x-4=0",
"lang": "EN"
}'
Replace YOUR_API_KEY
with the actual API key you generated.
3. Handling API Responses
When working with the API, you'll encounter varied and complex response data structures. For simplified integration, you can use the SDKs mentioned earlier. For those who prefer to handle responses directly via HTTP, the following sections provide detailed explanations and examples.
3.1 Definition of Response Structures (HTTP)
type V1SingleAnswerPost200Response struct {
Data *SolverSelfSimpleResponse `json:"data,omitempty"`
ErrMsg *string `json:"err_msg,omitempty"`
}
type V1BriefAnswersPost200Response struct {
Data *SolverSelfBriefResponse `json:"data,omitempty"`
ErrMsg *string `json:"err_msg,omitempty"`
}
type V1ShowStepsPost200Response struct {
Data *SolverSelfFullResponseText `json:"data,omitempty"`
ErrMsg *string `json:"err_msg,omitempty"`
}
type SolverSelfSimpleResponse struct {
Input *string `json:"input,omitempty"`
Solution *SolverSolution `json:"solution,omitempty"`
}
type SolverSelfBriefResponse struct {
Input *string `json:"input,omitempty"`
Solutions []SolverSolution `json:"solutions,omitempty"`
}
type SolverSelfFullResponseText struct {
Input *string `json:"input,omitempty"`
Solutions []SolverSolutionWithSolvingSteps `json:"solutions,omitempty"`
}
type SolverSolution struct {
BlockName *SolverDescription `json:"block_name,omitempty"`
Results []SolverStep `json:"results,omitempty"`
SolutionName *SolverDescription `json:"solution_name,omitempty"`
}
type SolverSolutionWithSolvingSteps struct {
BlockName *SolverDescription `json:"block_name,omitempty"`
Results []SolverStep `json:"results,omitempty"`
SolutionName *SolverDescription `json:"solution_name,omitempty"`
SolvingSteps []SolverStep `json:"solving_steps,omitempty"`
}
type SolverDescription struct {
Content *string `json:"content,omitempty"`
Format *SolverDescriptionFormat `json:"format,omitempty"`
}
type SolverStep struct {
Children []SolverStep `json:"children,omitempty"`
Description *SolverDescription `json:"description,omitempty"`
ImageUrl *string `json:"image_url,omitempty"`
Latex *string `json:"latex,omitempty"`
}
type SolverDescriptionFormat string
const (
TXT SolverDescriptionFormat = "txt"
LATEX SolverDescriptionFormat = "latex"
)
3.2 Access to show-steps API endpoint (HTTP)
package main
import (
"encoding/json"
"fmt"
)
/... The structures defined above/
func main() {
url := "https://api.cameramath.com/v1/show-steps"
appKeyID := "<replace_to_your_api_key>" // replace to your api key
reqBody := map[string]string{
"input": "x+1=2",
"lang": "EN",
}
jsonReqBody, err := json.Marshal(reqBody)
must(err)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonReqBody))
must(err)
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", apiKey)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
must(err)
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
fmt.Printf("Error: received non-200 status code: %d\n", resp.StatusCode)
return
}
body, err := ioutil.ReadAll(resp.Body)
must(err)
var response V1ShowStepsPost200Response
must(json.Unmarshal(body, &response))
fmt.Printf("Response: %+v\n", response)
}
func must(err error) {
if err != nil {
panic(err)
}
}
To call the single
or brief
API endpoints instead of the show-steps
API endpoint, you need to make the following changes:
- Modify the URL endpoint:
- For the
single
API endpoint, change theurl
variable tohttps://api.cameramath.com/v1/single-answer
.
- For the
brief
API endpoint, change theurl
variable tohttps://api.cameramath.com/v1/brief-answers
.
- For the
- Update the response handling:
- For the
single
API endpoint, modify the response structure to useV1SingleAnswerPost200Response
.
- For the
brief
API endpoint, modify the response structure to useV1BriefAnswersPost200Response
.
- For the
Other parts of the code, including constructing the request body, setting request headers, and processing the response, remain unchanged.
3.3 API Response Structure Explanation (HTTP/SDK)
Struct:V1SingleAnswerPost200Response
JSON Field | Struct Field | Type | Description |
data | Data | *SolverSelfSimpleResponse | Contains the main response object with the input and a simple answer to the most important topic. |
err_msg | ErrMsg | *string | Error message string |
Struct:V1BriefAnswersPost200Response
JSON Field | Struct Field | Type | Description |
data | Data | *SolverSelfBriefResponse | Contains the main response object with the input and a brief answer to multiple topics. |
err_msg | ErrMsg | *string | Error message string |
Struct:V1ShowStepsPost200Response
JSON Field | Struct Field | Type | Description |
data | Data | *SolverSelfFullResponseText | Contains the main response object with the input and step-by-step answers for multiple topics. |
err_msg | ErrMsg | *string | Error message string |
Struct: SolverSelfSimpleResponse
JSON Field | Struct Field | Type | Description |
input | Input | *string | The user's input in LaTeX format |
solution | Solution | *SolverSolution | The solution we believe the user most likely wants |
Struct: SolverSelfBriefResponse
JSON Field | Struct Field | Type | Description |
input | Input | *string | The user's input in LaTeX format |
solutions | Solutions | []SolverSolution | Contains all the solutions we can provide |
Struct: SolverSelfFullResponseText
JSON Field | Struct Field | Type | Description |
input | Input | *string | The user's input in LaTeX format |
solutions | Solutions | []SolverSolutionWithSolvingSteps | Contains all the solutions along with the steps to achieve them |
Struct: SolverSolutionWithSolvingSteps
JSON Field | Struct Field | Type | Description |
block_name | BlockName | *SolverDescription | Block name, e.g., Function/Solve the equation |
results | Results | []SolverStep | The answers, potentially multiple, for instance, \(\frac{1}{4}, 0.25\) |
solution_name | SolutionName | *SolverDescription | The specific name of the solution under the block type, e.g., Block: Function, Solution: Find the slope |
solving_steps | SolvingSteps | []SolverStep | The steps to achieve the solution |
Struct: SolverSolution
JSON Field | Struct Field | Type | Description |
block_name | BlockName | *SolverDescription | Block name, e.g., Function/Solve the equation |
results | Results | []SolverStep | The answers, potentially multiple e.g., \(\frac{1}{4}, 0.25\) |
solution_name | SolutionName | *SolverDescription | The specific name of the solution under the block, e.g., Block: Function, Solution: Find the slope |
Struct: SolverDescription
JSON Field | Struct Field | Type | Description |
content | Content | *string | Description content |
format | Format | *SolverDescriptionFormat | Format of the description content, either txt or latex |
Struct: SolverStep
JSON Field | Struct Field | Type | Description |
children | Children | []SolverStep | Sub-steps that supplement how this step leads to the next |
description | Description | *SolverDescription | Description of the current step |
image_url | ImageUrl | *string | If the step involves a drawing, this will contain the URL of the image |
latex | Latex | *string | The LaTeX representation of the current step |
Enum: SolverDescriptionFormat
Enum Value | Description |
TXT | Text format |
LATEX | LaTeX format |
SDKs
UpStudy provides Software Development Kits (SDKs) for various programming languages to aid seamless integration. Access the SDKs through the respective GitHub repositories:
1. Go
Github repo : GitHub Link
Examples:
Example in Go
Install the SDK
go get github.com/UpStudyTeam/[email protected]
Use SDK Example
package main import ( "context" "fmt" "github.com/UpStudyTeam/UpStudyGoSdk" ) func main() { configuration := UpStudyGoSdk.NewConfiguration() apiClient := UpStudyGoSdk.NewAPIClient(configuration) ctx := context.WithValue(context.Background(), UpStudyGoSdk.ContextAPIKeys, map[string]UpStudyGoSdk.APIKey{ "BearerAuth": { Key: "<your_api_key>", // TODO: change to your API key Prefix: "Bearer", }, }) resp, httpResp, err := apiClient.ThothEngineModuleAPI.V1SingleAnswerPost(ctx).Data(UpStudyGoSdk.RequestSolveRequestV1{ Input: "x+1=2", }).Execute() if err != nil { panic(err) } if httpResp.StatusCode != 200 { panic(httpResp.Status) } fmt.Println(resp) }
2. Python
Github repo : GitHub Link
Examples:
Example in Python
Install the SDK
sudo pip install git+https://github.com/UpStudyTeam/UpStudyPySdk.git
Use SDK Example
import upstudy_py_sdk from upstudy_py_sdk.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to https://api.cameramath.com # See configuration.py for a list of all supported configuration parameters. configuration = upstudy_py_sdk.Configuration( host = "https://api.cameramath.com" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: BearerAuth configuration.api_key['BearerAuth'] = "<replace_to_your_app_key_id>" # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['BearerAuth'] = 'Bearer' # Enter a context with an instance of the API client with upstudy_py_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = upstudy_py_sdk.ThothEngineModuleApi(api_client) data = upstudy_py_sdk.RequestSolveRequestV1(input="x+1=2",lang="EN") # RequestSolveRequestV1 try: api_response = api_instance.v1_brief_answers_post(data) print("The response of ThothEngineModuleApi->v1_brief_answers_post:\n") pprint(api_response) except ApiException as e: print("Exception when calling ThothEngineModuleApi->v1_brief_answers_post: %s\n" % e)
API Endpoints
The UpStudy API provides three primary endpoints to cater to different mathematical problem-solving needs. Each endpoint offers unique features and response structures. Below, you can see details about each endpoint, their request parameters, example requests, and response structures.
1. Single Answer
1.1 Endpoint
- URL :
https://api.cameramath.com/v1/single-answer
- Description : Provide quick responses to the main topic of the problem.
1.2 Request Parameters
- input (string, required): Arithmetic problem written in LaTeX format (e.g.,
"\\frac{x+1}{2} \\leq 0"
).
- lang (string, optional): The language code for the output. If not specified, the default language is English. Supported languages include:
["EN", "RU", "PT", "ES", "HI", "FR", "PL", "KO", "JA", "ZHS", "ZHT", "VI", "IT", "DE"]
.
1.3 Response Example
{
"data": {
"input": "x+1=2",
"solution": {
"block_name": {
"content": "Solve the equation",
"format": "txt"
},
"solution_name": {
"content": "\\text{Solve for }x",
"format": "latex"
},
"results": [
{
"description": {
"content": "\\text{Solve for }x",
"format": "latex"
},
"latex": "x=1"
}
]
}
}
}
Field descriptions:
- data: The top-level object containing the input equation and related solution information.
- input (
string
): The input equation or mathematical expression as a string.
- solution: The object containing the solution process and final result.
- block_name: The object containing the theme or topic of the solution process.
- content (
string
): The content of block_name (e.g., "Solve the equation").
- format (
string
): The format of the content.
- content (
- solution_name : The object containing the name or description of the solution.
- content (
string
): The content of the solution_name (e.g., "Solve the equation").
- format (
string
): The format of the content.
- content (
- results : An array containing one or more solution details.
- description : The description object for each solution detail.
- content (
string
): The description content of the solution detail (e.g., "\text{Solve for }x" describing solving for x).
- format (
string
): The format of the content .
- content (
- latex (
string
,optional): The final result of the solution in LaTeX string format (e.g., "x=1").
- description : The description object for each solution detail.
- block_name: The object containing the theme or topic of the solution process.
- input (
2. Brief Answers
2.1 Endpoint
- URL :
https://api.cameramath.com/v1/brief-answers
- Description : Provide an overview answer for each topic.
2.2 Request Parameters
- input (string, required): Arithmetic problem written in LaTeX format (e.g.,
"\\frac{x+1}{2} \\leq 0"
).
- lang (string, optional): The language code for the output. If not specified, the default language is English. Supported languages include:
["EN", "RU", "PT", "ES", "HI", "FR", "PL", "KO", "JA", "ZHS", "ZHT", "VI", "IT", "DE"]
.
2.3 Response Example
{
"data": {
"input": "x+1=2",
"solutions": [
{
"block_name": {
"content": "Solve the equation",
"format": "txt"
},
"solution_name": {
"content": "\\text{Solve for }x",
"format": "latex"
},
"results": [
{
"description": {
"content": "\\text{Solve for }x",
"format": "latex"
},
"latex": "x=1"
}
]
},
{
"block_name": {
"content": "Rewrite the equation",
"format": "txt"
},
"solution_name": {
"content": "Rewrite in standard form",
"format": "txt"
},
"results": [
{
"description": {
"content": "Rewrite in standard form",
"format": "txt"
},
"latex": "x=1"
}
]
},
{
"block_name": {
"content": "Graph",
"format": "txt"
},
"solution_name": {
"content": "Graph the equation",
"format": "txt"
},
"results": [
{
"description": {
"content": "Graph the equation",
"format": "txt"
},
"image_url": "https://static.cameramath.com/yc6uq9vds8/42f35af227a741c838471241303bf53e/72ccbc30081b38d1b1bc8dd2568901f9"
}
]
}
]
}
}
Field descriptions:
- data : The top-level object containing the input equation and related solutions.
- input (
string
): The input equation or mathematical expression as a string.
- solutions : An array of solution objects, each providing a different approach to solving or interpreting the problem.
- block_name: The object containing the theme or topic of the solution process.
- content (
string
): The content of block_name (e.g., "Solve the equation").
- format (
string
): The format of the content.
- content (
- solution_name : The object containing the name or description of the solution.
- content (
string
): The content of the solution_name (e.g., "Solve the equation").
- format (
string
): The format of the content.
- content (
- results : An array containing one or more solution details.
- description : The description object for each solution detail.
- content (
string
): The description content of the solution detail (e.g., "\text{Solve for }x" describing solving for x).
- format (
string
): The format of the content (e.g., "latex" for LaTeX format, "txt" for plain text).
- content (
- latex (
string
, optional): The final result of the solution in LaTeX string format (e.g., "x=1").
- image_url (
string
, optional): The URL pointing to an image representing the solution (e.g., a graph of the equation).
- description : The description object for each solution detail.
- block_name: The object containing the theme or topic of the solution process.
- input (
3. Show steps
3.1 Endpoint
- URL :
https://api.cameramath.com/v1/show-steps
- Description : A detailed step-by-step walkthrough for each topic.
3.2 Request Parameters
- input (string, required): Arithmetic problem written in LaTeX format (e.g.,
"\\frac{x+1}{2} \\leq 0"
).
- lang (string, optional): The language code for the output. If not specified, the default language is English. Supported languages include:
["EN", "RU", "PT", "ES", "HI", "FR", "PL", "KO", "JA", "ZHS", "ZHT", "VI", "IT", "DE"]
.
3.3 Response Example
{
"data": {
"input": "\\log_{4}{\\left(x+1\\right)}=3",
"solutions": [
{
"block_name": {
"content": "Solve the equation",
"format": "txt"
},
"solution_name": {
"content": "\\text{Solve for }x",
"format": "latex"
},
"results": [
{
"description": {
"content": "\\text{Solve for }x",
"format": "latex"
},
"latex": "x=63"
}
],
"solving_steps": [
{
"description": {
"content": "Evaluate",
"format": "txt"
},
"latex": "\\log_{4}{\\left(x+1\\right)}=3",
"children": [
{
"description": {
"content": "Evaluate",
"format": "txt"
},
"latex": "x+1>0"
},
{
"description": {
"content": "Move the constant to the right side",
"format": "txt"
},
"latex": "x>0-1"
},
{
"description": {
"content": "Remove 0",
"format": "txt"
},
"latex": "x>-1"
}
]
},
{
"description": {
"content": "Find the domain",
"format": "txt"
},
"latex": "\\log_{4}{\\left(x+1\\right)}=3,x>-1"
},
{
"description": {
"content": "Convert the logarithm into exponential form",
"format": "txt"
},
"latex": "x+1=4^{3}"
},
{
"description": {
"content": "Evaluate the power",
"format": "txt"
},
"latex": "x+1=64"
},
{
"description": {
"content": "Move the constant to the right side",
"format": "txt"
},
"latex": "x=64-1"
},
{
"description": {
"content": "Subtract the numbers",
"format": "txt"
},
"latex": "x=63"
},
{
"description": {
"content": "Check if the solution is in the defined range",
"format": "txt"
},
"latex": "x=63,x>-1"
},
{
"description": {
"content": "Find the intersection",
"format": "txt"
},
"latex": "x=63"
}
]
},
{
"block_name": {
"content": "Graph",
"format": "txt"
},
"solution_name": {
"content": "Graph the equation",
"format": "txt"
},
"results": [
{
"description": {
"content": "Graph the equation",
"format": "txt"
},
"image_url": "https://static.cameramath.com/yc6uq9vds8/fe62e4ab1839887b234e4d144e54f8ac/485092d15060a9d7b429ae6097208232"
}
],
"solving_steps": [
{
"description": {
"content": "Evaluate",
"format": "txt"
},
"latex": "x=63"
},
{
"description": {
"content": "Graph",
"format": "txt"
},
"image_url": "https://static.cameramath.com/yc6uq9vds8/fe62e4ab1839887b234e4d144e54f8ac/485092d15060a9d7b429ae6097208232"
}
]
}
]
}
}
Field descriptions:
- data : The top-level object containing the input equation and related solutions.
- input (
string
): The input equation or mathematical expression as a string.
- solutions : An array of solution objects, each providing a different approach to solving or interpreting the problem.
- block_name: The object containing the theme or topic of the solution process.
- content (
string
): The content of block_name (e.g., "Solve the equation").
- format (
string
): The format of the content.
- content (
- solution_name : The object containing the name or description of the solution.
- content (
string
): The content of the solution_name (e.g., "Solve the equation").
- format (
string
): The format of the content.
- content (
- results : An array containing one or more solution details.
- description : The description object for each solution detail.
- content (
string
): The description content of the solution detail (e.g., "\text{Solve for }x" describing solving for x).
- format (
string
): The format of the content (e.g., "latex" for LaTeX format, "txt" for plain text).
- content (
- latex (
string
, optional): The final result of the solution in LaTeX string format (e.g., "x=1").
- image_url (
string
, optional): The URL pointing to an image representing the solution (e.g., a graph of the equation).
- description : The description object for each solution detail.
- solving_steps : An array containing the detailed steps of the solution process.
- description : The description object for each solving step.
- content (
string
): The description content of the step (e.g., "Evaluate").
- format (
string
): The format of the description content .
- content (
- latex (
string
, optional): The intermediate result at this step in LaTeX string format (e.g., "x+1=2").
- image_url (
string
, optional): The URL pointing to an image representing this step (e.g., a graph at this stage).
- children (
array
, optional): An array containing child step objects for further detailing a particular step. Each child step follows the same structure assolving_steps
.
- description : The description object for each solving step.
- block_name: The object containing the theme or topic of the solution process.
- input (
Exploring the API with Swagger UI
Use the Swagger UI to explore all available API endpoints and their details.
Accessing Swagger UI:
- Open your browser and navigate to: Swagger link
With the Swagger UI, you can:
- View all API endpoints.
- Read detailed descriptions for each endpoint.
- Test API calls directly from the interface
Error Handling
Response code | Description | Solution |
400 | Invalid Request | Check if the request parameters are correct. |
401 | Unauthorized | Ensure the API key is correct and valid. |
429 | Too Many Requests | Reduce the request rate and adhere to the API usage limits. |
500 | Server Error | Retry after some time; if the issue persists, contact the support team. |
The UpStudy API has a rate limit of 30 requests per minute. Exceeding this limit results in a 429 status code (Too Many Requests
).
For higher rate limits, please contact [email protected] for customized rate limit options.
Supported Topics and Examples
Below is a table of mathematical topics and subtopics that our API can handle, along with LaTeX examples for each. This can help you understand the range of problems our API can solve and how to format your inputs correctly.
Topics | Sub-topics | example | latex |
Pre Algebra | Fractions | | \frac{5}{8}+\frac{7}{8} |
Decimals | | 7.19\times 19.61 | |
Exponents | | 2^2\times 2^5 | |
Radicals | | \sqrt{18} | |
Ratios | | 3:5 | |
Integer | | (27+31)\times 12 | |
Percent | | 18\% | |
Algebra | Equations | | 5x-3=52 |
Expressions | | 9x-24x+16= | |
Inequalities | | 3x-5>-2(x-10) | |
Functions | | y=x+7,x=2 | |
Sequences | | 10,8,6,\cdots | |
Logarithmic | | \log _32x=9 | |
Complex Number | | (6+3i)(5-6i)= | |
Matrices | | \left[\begin{array}{l} {4}&{5}\\{-3}&{2}\end{array}\right]= | |
Pre Calculus | Equations | | \frac{x}{5}+\frac{x}{5}=10 |
Inequalities | | \left|2x+1\right|>7 | |
Functions | | f(x)=x^3 | |
Calculus | Derivatives | | \frac{d}{dx}(2x-5)= |
integrals | | \int _{ }^{ }5xdx= | |
Limits | | \lim_{x\rightarrow \infty }\frac{\left|x\right|}{x}= | |
Series | | \sum _{n=1}^{\infty }\frac{1}{n(n+1)}= | |
Trigonometry | Equations | | \sin (x)-\cos (x)=0 |
Inequalities | | \cos (2x)+2\sin ^2(x)>0 | |
Functions | | \sin 75^{\circ }\cos 15^{\circ }+\sin 15^{\circ }\cos 75^{\circ }= | |
Simplify | | \frac{1+\tan \theta }{1+\cot \theta }=\tan \theta | |
Proof | | \frac{\tan \theta }{\sec \theta }=\sin \theta | |
Geometry | | \frac{x^2}{36}+\frac{y^2}{9}=1 | |
Statistics and Probability | | 5!= |