Using Project Access Token¶
In this guide, we'll explore how to interact with DATAMIMIC projects programmatically using project access tokens. This approach allows you to manage your projects and generate data through API calls, which is particularly useful for automation and CI/CD pipelines.
Prerequisites¶
- Take a look at the DATAMIMIC External API Reference or access your datamimic instance
external_api_docs
to understand the API endpoints and how to use them - A DATAMIMIC project
- curl installed on your system
- jq (Optional) installed on your system (for JSON artifact processing)
Getting Started¶
- Clone the Demo Basic JSON from the DATAMIMIC Demo Store.
- Add a new project access token for this newly clone demo project.
- Note down both the Project ID and the newly Project Access Token.
Basic Operations¶
Reading Project Files Metadata¶
To get all your project's files metadata information:
1 2 3 4 |
|
Reading a Project File Content¶
To get a project file content:
1 2 3 4 |
|
Creating a Project File¶
To create a new project file, you can use the curl
command with the -F
flag to upload the contents of a local file directly, instead of specifying the file content inline.
Note
New file can only be created if it not already exists in the project. Otherwise, you need to update the existing file.
1 2 3 4 5 6 |
|
Updating Project Files¶
Make any change you want to the file content locally then update it to the system.
Note
A file can only be updated if it already exists in the project. If it doesn't exist, you need to create it first.
To update a file's content:
1 2 3 4 5 6 |
|
Deleting a Project File¶
To delete a project file:
1 2 3 4 |
|
Generating Data¶
To trigger data generation:
1 2 3 4 5 |
|
This call will return a Task ID that you can use to track the generation progress and download artifacts.
Downloading Generated Data¶
To download and view generated artifacts:
1 2 3 4 |
|
or you can also download all the artifacts created by the task as a single zip file:
1 2 3 4 |
|
Example Workflow¶
Here's a complete example of a typical workflow:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
Note
Replace your-datamimic-instance
, {project-id}
, {task-id}
and {your-access-token}
with your actual values in all examples.
Tips¶
You can visit the external_api_docs
to see the API endpoints, these endpoints contains clear examples and documentation using our Swagger UI for you to try out the API endpoints.
Using the Swagger UI, you can also see the curl
command to use the API endpoints. This can make the API calls easier to understand and use.
Recap¶
In this guide, we explored how to programmatically interact with DATAMIMIC projects using project access tokens. Here's a summary of the key concepts and operations:
-
Setup and Authentication:
- Created/used a DATAMIMIC project
- Generated a project access token
- Used the token for API authentication
-
Basic Operations:
- Reading project files using GET requests
- Updating file content using POST requests
- Triggering data generation
- Downloading and viewing generated artifacts
-
Workflow Integration:
- Learned how to combine operations into a complete workflow
- Used environment variables for configuration
- Implemented basic automation patterns
These API operations enable you to automate DATAMIMIC project management and integrate it into your development workflows, CI/CD pipelines, or custom applications.