Rest API
Xygeni REST API
The Xygeni API is based on the OpenAPI ("Swagger") standards and allows retrieval of security issues, project risk summary, trends in security position, and report generation, plus administration.
The api base URL is https://api.xygeni.io
API Endpoints
Most Xygeni API endpoints return JSON output.
The easiest way to find the endpoint for a particular need is by browsing in the online API documentation.
Generating an API client
Instead of providing a downloadable client for different platforms / languages, it is recommended to generate the client from the OpenAPI specification (if you trust the publicly available generators). This allows to control the generation of the client, and keeps it updated to the latest API version.
For generating an api client for a target programming language, the OpenAPI / Swagger specification can be downloaded from https://get.xygeni.io/latest/swagger/swagger.yaml (YAML) or https://get.xygeni.io/latest/swagger/swagger.json (JSON).
Method 1: Using Swagger editor
The most interactive way to create a client from a swagger file is using the online swagger editor. Go to Use https://editor-next.swagger.io/. Select file, import URL and type in the URL of the Xygeni API URL. Alternatively you can select File
, Import File and upload the downloaded swagger.yaml file.
Next select Generate Client
and select the language of your choice. The end result is a zip file you can download with the generated client code.
Method 2: Using swagger-codegen
Instead of using the interactive editor, you may use the swagger-codegen. This is the recommended alternative in general, as it provides much more control on the generated client code.
Method 3: Using OpenAPI Generator
OpenAPI Generator is another nice client generator for api clients from OpenAPI / Swagger documents.
You may download the openapi-generator-cli.jar
and run its help command:
There are other alternatives that wrap the Java-based OpenAPI generator CLI, that you may try for convenience. You may then replace java -jar openapi-generator-cli.jar
with openapi-generator-cli
command, for example.
It is recommended to define a configuration file like my_config.yaml
with options for your language of choice, and then call the generator with the config file:
Usage
An api client generated for your language of choice could be convenient. Alternatively, there are popular frameworks for invoking api endpoints that could be used. A third option is to use a command-line tool like curl
or wget
.
The online API documentation is the reference to the available endpoints.
Authentication
Most API endpoints require authentication (except /ping
to check for platform availability). The recommended way to authenticate operations is using an access token (also known as apikey
or API token
). Go to Generate Access Token for full details.
Authenticating api calls require an Authorization header: Authorization: Bearer <TOKEN_HERE>
.
Let’s assume that the access token is set in the XYGENI_TOKEN
environment variable. The following is an example using curl
for the /secret
endpoint:
The Xygeni API may use also basic authentication with username and password, but it is not recommended. Use an access token instead.
An example of basic authentication with curl on the same endpoint:
As a shorthand, in the following examples, a XY_API_TOK
environment variable with value Authorization: Bearer ${XYGENI_TOKEN}
will be used.
Fetching data
Most endpoints for fetching issues need a projectId
parameter. The list of project IDs for the organization’s projects could be fetched using the GET /projects/list endpoint:
The Analysis endpoints could be used to fetch data for the different issue types. For example, to get the latest misconfigurations:
Administration
Create projects
For automation, you may need to create projects. The POST /project/create endpoint creates a project.
You need MANAGER_PROJECT or ROOT roles for creating projects for your organization.
Delete project
Sometimes projects terminate, software is decommissioned or replaced, and so on. The DELETE /project/{projectId} allows to remove a given project AND ALL ITS DATA.
This is a destructive operation. Project data is removed from the platform.
Last updated