> ## Documentation Index
> Fetch the complete documentation index at: https://support.myapps.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Pixio API Development

> Learn how to interact with the Pixio API to trigger workflows and upload files

<Info>
  **Prerequisite**: You should have Node.js (version 18.10.0 or higher) and an API token from the Pixio dashboard.
</Info>

### Step 1: Install the Pixio API SDK

To start interacting with the Pixio API, you need to install the Pixio SDK using npm or yarn:

```bash npm theme={null}
npm install @pixio/api-sdk `

`yarn add @pixio/api-sdk`

```

### Step 2: Configure API Key

Once the SDK is installed, create a `.env` file in your project to securely store your Pixio API key.

```bash npm theme={null}

`PIXIO_API_KEY=your-api-key-here`

```

### Step 3: Set up the Pixio API Client

Next, set up the Pixio API client in your code:

```bash npm theme={null}

`const PixioAPI = require('@pixio/api-sdk');
const client = new PixioAPI(process.env.PIXIO_API_KEY);

// Example: Fetch workflow projects
client.getProjects().then(projects => {
  console.log(projects);
});`

```

### Step 4: Running a Workflow

You can trigger a workflow by making a POST request to the `/run` endpoint with the deployment ID and input data:

```bash npm theme={null}

`client.runWorkflow({
  deployment_id: "your-deployment-id",
  inputs: {
    input_text: "Example input",
    input_image: "https://example.com/image.png"
  }
}).then(response => {
  console.log('Run ID:', response.run_id);
});`
```

### Step 5: Retrieve Workflow Output

After triggering the workflow, you can retrieve the output using the `run_id`:

````bash npm theme={null}

`client.getWorkflowOutput("your-run-id").then(output => {
  console.log('Output:', output);
});`

### Step 6: Uploading Files

To upload a file (image, document, etc.), you need to first get an upload URL:

```bash npm

`client.getUploadUrl({
  type: "image/png",
  file_size: 102400
}).then(response => {
  console.log('Upload URL:', response.upload_url);
  console.log('File ID:', response.file_id);
});`
````

### Custom Ports

Pixio API calls are generally executed on standard ports. If you are working in a local development environment and need to customize the port for running your Node.js app:

```bash npm theme={null}

`const PORT = process.env.PORT || 3333;
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));`
```

### Common Errors

If you encounter any errors such as `EADDRINUSE` or other port-related issues, make sure that no other services are running on the same port.

```bash npm theme={null}

`Error: listen EADDRINUSE: address already in use :::3000`
```

## Pixio API Versions

To ensure compatibility with the latest Pixio API features, keep the SDK up-to-date:

```bash npm theme={null}

`npm update @pixio/api-sdk`

`yarn upgrade @pixio/api-sdk`
```

## Deployment

<Tip> Once you've built your Pixio-powered application, you can deploy it on platforms like Vercel, Heroku, or AWS. For more details, check the [Pixio API Documentation](https://support.myapps.ai/api-reference/endpoint/get). </Tip>

If you have any issues please contact us.

## Troubleshooting

If you run into any issues while working with the Pixio API, here are a few troubleshooting steps:

<AccordionGroup> <Accordion title="Invalid API Key"> Ensure your `.env` file is correctly set up with your Pixio API key. Regenerate the API key if needed from the dashboard. </Accordion> <Accordion title="Token Expired or Invalid"> Make sure your token is valid and hasn't expired. You can renew it in the Pixio API dashboard under API Keys. </Accordion> <Accordion title="API Response Errors"> If you receive unexpected responses from the API, try resetting your environment and reinstalling dependencies by running `npm install` or `yarn install`. </Accordion> </AccordionGroup>

For further details on the Pixio API, check out the API Reference.
