---
agentTools:
  projectIndex: https://hub.phantombuster.com/llms.txt
---

# SDK: automatically publish code to Phantombuster

Code locally on your machine, within your favorite IDE, using your favorite tools!

All your scripts can easily be written right on our website, in our JavaScript web editor.

However, you might prefer using your own editor, locally on your machine. We made [Phantombuster's SDK](https://www.npmjs.com/package/phantombuster-sdk) specifically for this.

The SDK will **monitor a directory** on your disk for changes in your scripts. As soon as a change is detected, the script will be uploaded in your Phantombuster account.

No more tab switching: you code, you save and you can immediatly launch your updated <<glossary:script>> on your console.

[block:api-header]
{
  "type": "basic",
  "title": "Installation"
}
[/block]

You can install it using [npm](https://www.npmjs.com/package/phantombuster-sdk):

[block:code]
{
  "codes": [
    {
      "code": "npm install -g phantombuster-sdk",
      "language": "shell",
      "name": null
    }
  ]
}
[/block]

This will install the `phantombuster` command globally (you might have to run its installation as root with `sudo` in front).

[block:api-header]
{
  "title": "Setup"
}
[/block]

First of all, create the folder in which you are going to work and go into it:

[block:code]
{
  "codes": [
    {
      "code": "mkdir my-custom-script\ncd my-custom-script",
      "language": "shell"
    }
  ]
}
[/block]

In this folder, just create a configuration file named `phantombuster.cson`. Here's what you'll need to write inside it:

[block:code]
{
  "codes": [
    {
      "code": "[\n    name: 'account name'\n    apiKey: 'YOUR_API_KEY_HERE'\n    scripts:\n        'my-script.js': 'project/test/my-script.js'\n        'another-script.coffee': 'folder/script.coffee'\n]",
      "language": "coffeescript",
      "name": "phantombuster.cson"
    }
  ]
}
[/block]

* `name`: The account name is an arbitrary `String` of your choice. People generally put in the name of their Phantombuster account.
  This name is shown each time a script is successfully saved on Phantombuster’s servers.
* `apiKey`: The API key must contain the API key of your Phantombuster account as a `String`. Please refer to our [guide on how to find my API key](https://hub.phantombuster.com/docs/api#how-to-find-my-api-key) for detailled instructions.
* `scripts`: This is a `Plain Object` containing a list of scripts that you wish to manage with the SDK.
  Each line (key/value pair) represents a script. The key (left side) is the script’s name on Phantombuster (therefore it must not contain any special characters or any slashes). The value (right side) is the location of this script’s file on your machine’s disk, in your project directory (in fact, relative to the location of phantombuster.cson).

[block:api-header]
{
  "title": "Use it"
}
[/block]

Now you just have to launch the SDK and it will watch for changes to upload them to your Phantombuster account. To start the SDK, simply navigate to your project directory and execute the `phantombuster` command:

[block:code]
{
  "codes": [
    {
      "code": "cd my-custom-script\nphantombuster",
      "language": "shell"
    }
  ]
}
[/block]

This will start a monitoring process. If any modification happens to your script's files, they will automatically be saved in your Phantombuster account.

It means you can now start the editor of your choice and start developing your scripts in an environment you like, using your favorite tools!

[block:image]
{
  "images": [
    {
      "image": [
        "https://files.readme.io/2c06a39-Jul-03-2017_11-50-02.gif",
        "Jul-03-2017 11-50-02.gif",
        570,
        284,
        "#1b1b1b"
      ],
      "caption": "Watch the magic happen!"
    }
  ]
}
[/block]

[block:callout]
{
  "type": "info",
  "title": "Advanced usage",
  "body": "`phantombuster [-c config.cson] [script1.coffee [script2.coffee...]]`\nYou can specify another configuration file with the -c option.\nYou can also provide one or more script paths to upload them to your Phantombuster account (without starting the monitoring process)."
}
[/block]