Endpoints
render_lines
GET
https://codemeup.vercel.app/api/{username}/{repository}/render_lines
This endpoint allows to render code directly from Github.
The username path parameter is used to authenticate to the Codemeup backend and is the same as the Github username.
The repository path parameter is used to identify the repository from which the code is taken. It is possible to specify also repository owned by an organization using the following format: {organization}@{repository}.
It is important to remember that the specified organization must be owned by the provided user!
Query parameters
ID | Description | Values |
---|---|---|
path [Required] | The relative path of the file to render in the specified repo | Any string path format. This path can be copied from the top bar while navigating a repository in Github |
branch | The branch name to consider | Any existing branch. Do not provide this parameter to use the default branch |
fragment | The fragment to render (portion of lines) | A string in format <rowFrom>-<rowTo>. Do not provide this parameter to render the whole file |
render_source
POST
https://codemeup.vercel.app/api/{username}/render_source
This endpoint allows to render code by passing the source directly into the body of the request.
The username path parameter is used to authenticate to the Codemeup backend and is the same as the Github username.
Body parameters
ID | Description | Values |
---|---|---|
src | The source code | Any source code in string format |
lang | The language of the code | The language is used to format and highlight the code. Available languages are |
Styling options
Styling options can be appended to any endpoint and are responsible to override the aspect of the final render.
ID | Description | Values |
---|---|---|
theme | Select the theme of the code highlighter | All themes supported by Shiki |
border-radius | The border radius of the background | Any number expressed in pixels |
padding | The padding of the text from the border | Any number expressed in pixels |
bg | Override the color of the background | Any color in hex format. The character # must be escaped as %23. Use transparent to remove the background. |
font-family | Set the font family | Any font family supported by Google. All families available here |
width | Override the width of the .svg | Any width format accepted by the web |
height | Override the height of the .svg | Any height format accepted by the web |
Response formatting
It is possible to use the endpoints and obtain a formatted response instead of a plain xml svg element.
If the format query parameter is not provided, the response will be a image/svg+xml.
raw
Raw data returns the plain image/svg+xml element.
structured
Structured data returns a text/json object with the following structure:
ID | Description |
---|---|
request | The incoming request structured in an object |
formatted | Whether the code has been formatted |
codeHtml | The self-contained styled code in html format |
html | The complete image/svg+xml html code |