Specify Docs
Specify ↗︎Changelog ↗︎Guide ↗︎
V2
V2
  • Getting started
    • Introduction
    • What is Specify?
    • Pulling your first tokens with the CLI
    • Glossary
  • Collect
    • What is a Source?
    • Available sources
      • Figma Variables & Styles
      • Tokens Studio
  • Distribute
    • What is a Destination?
    • Available destinations
      • GitHub
      • Specify CLI
      • Specify SDK
      • HTTP API
  • Concepts
    • Overview
    • Parsers Engine
    • SDTF Client
      • SDTF Engine
    • Specify Design Token Format
  • Guides
    • Configuration file 101
    • Specify CLI usage 101
      • Getting started
      • Authentication
      • Generate Files
    • Specify SDK usage 101
      • Getting started
      • Retrieving and working with the tokens
      • Updating tokens
      • Converting a token to XXX
      • Executing generation parsers
    • Specify SDK Cheatsheet
    • Manage font files
    • Querying a SDTF graph
  • Reference
    • Parsers Engine
    • Parsers
      • change-case
      • convert-color
      • convert-dimension
      • make-line-height-relative
      • filter
      • register-view
      • select-modes
      • prefix-by
      • suffix-by
      • replace-string
      • to-css-custom-properties
      • to-css-text-style
      • to-css-font-import
      • to-flutter
      • to-javascript
      • to-json
      • to-json-list
      • to-kotlin
      • to-react-native
      • to-scss-mixin-text-style
      • to-scss-map
      • to-sdtf
      • to-style-dictionary
      • to-swift
      • to-tailwind
      • to-typescript
      • svgo
      • svg-to-jsx
      • svg-to-tsx
      • to-svg-file
      • to-bitmap-file
      • to-file
    • Specify SDK
      • SpecifyClient
      • SDTFClient
      • Converters
        • CSS
      • ParsersEngineResults
    • SDTF Engine
      • Query API
      • Mutation API
      • SDTF Query Language
      • SDTF QueryResult
      • TokenState
        • Stateful Value
    • HTTP API
      • POST /parsers-engine-rpc
    • Specify CLI
  • Resources
    • Parser Rules templates
      • CSS Custom Properties
      • Tailwind
      • React Native
      • Flutter
      • SDTF
      • JSON
    • Specify CLI VS Specify SDK
    • Playground
    • Best practices
  • Useful links
    • Discord
    • YouTube
    • Twitter
    • Help Center
    • Canny
Powered by GitBook
On this page
  • Route
  • Headers
  • Request Body
  • Response Body
  • Example

Was this helpful?

Export as PDF
  1. Reference
  2. HTTP API

POST /parsers-engine-rpc

Execute the Parsers Engine against a given input and Parsers Rules.

Route

Method: POST

Authentication: required

Url:

https://api.specifyapp.com/v2/parsers-engine-rpc

Headers

Content-Type: application/json
Authorization: PAT <your-personal-access-token>

Request Body

type ParsersEngineRPCRequestBody = {
  dataBox: ParsersEngineDataBox;
  rules: Array<ParserRule>;
  returnedKeys?: {
    output?: boolean;
    next?: boolean;
    errorMessages?: boolean;
    warningMessages?: boolean;
    informationMessages?: boolean;
  };
};
Name
Type
Description

dataBox

The initial state to launch the parsers engine from.

rules

The parser rule definitions to instruct the transformation and generation pipelines.

returnedKeys

Record<string, boolean | undefined> | undefined

Select which response keys should be present. Defaults to true.

Response Body

type ParsersEngineResults = Array<{
  pipelineName: string;
  isFromRule: boolean;
  status: "success" | "error";
  output:
    | {
        type: "files";
        files: Array<{
          path: string;
          content:
            | { type: "text"; text: string }
            | { type: "url"; url: string };
        }>;
      }
    | {
        type: "JSON";
        json: unknown;
      }
    | {
        type: "text";
        text: string;
      }
    | {
        type: "SDTF";
        graph: SpecifyDesignTokenFormat;
      }
    | null;
  next: ParsersEngineDataBox | undefined;
  errorMessages: Array<{
    type: "error";
    content: string;
    errorKey: string;
  }>;
  warningMessages: Array<{
    type: "warning";
    content: string;
    errorKey: string;
  }>;
  informationMessages: Array<{
    type: "information";
    content: string;
  }>;
}>;

The response is an array where each item is the result of the rule given in the request, at the same index.

The output type matches the output configured within the rule given in the request.

The route always respond with a 200 code. Error state is represented by the status property in response object.

Example

Here's a simple example to get the raw tokens in JSON from a repository called all-design-datain the @acme-inc workspace:

curl -X POST 'https://api.specifyapp.com/v2/parsers-engine-rpc' \
--header 'Authorization: PAT <YOUR-PERSONAL-ACCESS-TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
  "dataBox": {
    "type": "repository",
    "owner": "@acme-inc",
    "name": "all-design-data"
  },
  "rules": [
    {
      "name": "HTTP Extract",
      "parsers": [
        {
          "name": "to-sdtf",
          "output": {
            "type": "file",
            "filePath": "tokens.json"
          }
        }
      ]
    }
  ]
}'
PreviousHTTP APINextSpecify CLI

Last updated 1 year ago

Was this helpful?

Array<>

ParsersEngineDataBox
ParserRule