{"id":20056293,"url":"https://github.com/chialab/math-api","last_synced_at":"2025-05-05T14:30:20.524Z","repository":{"id":44126456,"uuid":"84941245","full_name":"chialab/math-api","owner":"chialab","description":"➗ Serverless API to render maths using MathJax for Node.","archived":false,"fork":false,"pushed_at":"2022-12-10T17:24:17.000Z","size":247,"stargazers_count":44,"open_issues_count":14,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-09T00:11:09.434Z","etag":null,"topics":["aws-apigateway","aws-lambda","docker","hacktoberfest","latex","mathml","nodejs","serverless"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chialab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-14T11:27:11.000Z","updated_at":"2025-03-02T10:29:44.000Z","dependencies_parsed_at":"2023-01-26T06:46:46.078Z","dependency_job_id":null,"html_url":"https://github.com/chialab/math-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chialab%2Fmath-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chialab%2Fmath-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chialab%2Fmath-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chialab%2Fmath-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chialab","download_url":"https://codeload.github.com/chialab/math-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252514721,"owners_count":21760421,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-apigateway","aws-lambda","docker","hacktoberfest","latex","mathml","nodejs","serverless"],"created_at":"2024-11-13T12:53:08.255Z","updated_at":"2025-05-05T14:30:20.205Z","avatar_url":"https://github.com/chialab.png","language":"JavaScript","readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.chialab.io/p/proteins\"\u003e\n        \u003cimg alt=\"Math API logo\" width=\"144\" height=\"144\" src=\"https://raw.githack.com/chialab/math-api/master/logo.svg\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cstrong\u003eMath API\u003c/strong\u003e • Render LaTeX and MathML formulas as SVG or PNG.\n\u003c/p\u003e\n\n---\n\nA REST API to do fancy things with formulas, like rendering LaTeX or MathML to\nSVG or PNG on the server side using [MathJax for Node](https://github.com/mathjax/MathJax-node),\nwhile leveraging expensive computations on the client.\n\n## As a Serverless application\n\nYou can deploy this repository as a serverless application using an AWS CloudFormation\nTemplate to create an AWS API Gateway that invokes Lambda functions to serve requests.\n\n\u003e [**Launch this stack on AWS**](https://console.aws.amazon.com/cloudformation/home#/stacks/new?stackName=MathApi\u0026templateURL=https://chialab-cloudformation-templates.s3-eu-west-1.amazonaws.com/chialab/math-api/master/template.yml)\n\n## As a Docker image\n\nYou can pull and run a Docker container to deploy the API on your local machine,\nserver, Kubernetes cluster, whatever!\n\nTo start the container (it will bind on \u003chttp://localhost:3000/\u003e):\n\n```sh\ndocker run --name math-api -d -p 3000:3000 chialab/math-api\n```\n\n## Endpoints\n\n- [`GET /render`](#get-render)\n- [`POST /render`](#post-render)\n\n### `GET /render`\n\n\u003e An endpoint to render LaTeX and MathML formulas to SVG or PNG.\n\n**Query parameters**:\n\n- `input` (**required**): the format of math in input.  \n   **Valid values**: `latex`, `mathml`\n- `inline` (_optional_): when `input` is `latex`, optionally enable \"inline\" mode.  \n   **Valid values**: `0`, `1`\n- `source` (**required**): the math to be rendered.  \n   **Valid values**: _string, depends on the input type_\n- `output` (**required**): the output format.  \n   **Valid values**: `mathml`, `png`, `svg`\n- `width`, `height` (_optional_): when `output` is `png`, specify the dimensions of the image to return.  \n   **Valid values**: _positive integers_\n\n**Examples**:\n\n```http\nGET /render?input=latex\u0026output=svg\u0026source=x^2 HTTP/1.1\nAccept: image/svg+xml\n```\n\n```http\nGET /render?input=latex\u0026inline=1\u0026output=png\u0026source=x^2\u0026width=512 HTTP/1.1\nAccept: image/png\n```\n\n### `POST /render`\n\n\u003e An endpoint to render LaTeX and MathML formulas to SVG or PNG.\n\n**Request body (JSON)**:\n\n- `input` (**required**): the format of math in input.  \n   **Valid values**: `latex`, `mathml`\n- `inline` (_optional_): when `input` is `latex`, optionally enable \"inline\" mode.  \n   **Valid values**: _boolean_\n- `source` (**required**): the math to be rendered.  \n   **Valid values**: _string, depends on the input type_\n- `output` (**required**): the output format.  \n   **Valid values**: `mathml`, `png`, `svg`\n- `width`, `height` (_optional_): when `output` is `png`, specify the dimensions of the image to return.  \n   **Valid values**: _positive integers_\n\n**Examples**:\n\n```http\nPOST /render\nAccept: image/svg+xml\nContent-Type: application/json\n\n{\n    \"input\": \"latex\",\n    \"output\": \"svg\",\n    \"source\": \"e^{i \\\\pi} + 1 = 0\"\n}\n```\n\n```http\nPOST /render\nAccept: image/png\nContent-Type: application/json\n\n{\n    \"input\": \"latex\",\n    \"inline\": true,\n    \"output\": \"png\",\n    \"source\": \"e^{i \\\\pi} + 1 = 0\",\n    \"width\": 512\n}\n```\n\n## Development\n\n_All the following instructions assume you have at least [NodeJS](https://nodejs.org/) and [Yarn](https://yarnpkg.com/) installed._\n\n**Start the application locally**:\n\u003e `yarn start`\n\n**Run unit tests**:\n\u003e `yarn run test`\n\n**Start a simulated AWS API Gateway** (_provided you have AWS SAM Local and Docker installed_):\n\u003e `yarn run api-gateway`\n\n**Validate CloudFormation template** (_provided you have AWS CLI installed_)\n\u003e `make validate`\n\n**Package CloudFormation template** (_provided you have AWS CLI and Docker installed_)\n\u003e `make layers` (_this is needed only the first time, then when updating MathJax version_)\n\u003e `make package`\n\n**Deploy CloudFormation template** (_provided you have AWS CLI and Docker installed_)\n\u003e `make deploy`\n\u003e `make deploy ENVIRONMENT=Production`\n\n---\n\n## License\n\nMath API is released under the [MIT](https://github.com/chialab/math-api/blob/master/LICENSE) license.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchialab%2Fmath-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchialab%2Fmath-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchialab%2Fmath-api/lists"}