API Credentials for Yourls

Guide to obtaining tokens, keys, and connections.

To use the YOURLS API you need two essential pieces of information: 1) the "Domain", which is the base URL of your YOURLS installation where the file yourls-api.php is located, and 2) the "Token", a unique secret key YOURLS generates for your user and that must be sent with every API request. Below you will find detailed steps to locate both pieces of information.

Domain

  1. 1

    Open your browser and go to the YOURLS login page. It is usually something like https://yourdomain.com/admin/ (or the folder where you installed YOURLS).

  2. 2

    Log in with your YOURLS username and password.

  3. 3

    Once inside the admin panel, look at your browser’s address bar. Everything that appears before /admin/ (or before /yourls-api.php) is your "Domain." Example: if you see https://yourdomain.com/admin/tools.php, your Domain is https://yourdomain.com.

  4. 4

    To confirm the API responds, append /yourls-api.php at the end and open that address in a new tab. You should see an error message saying the token is missing, which means the URL is correct.

Token

  1. 1

    In the YOURLS admin panel, click the “Tools” menu in the top bar.

  2. 2

    Scroll down to the section called “Secure passwordless API call.” You will see a box that says "Your secret signature token is:" followed by a string of letters and numbers.

  3. 3

    Copy that string exactly; that is your "Token." Do NOT share this value publicly.

  4. 4

    To verify it works, open a new tab and visit: /yourls-api.php?signature=&action=stats. You should see a JSON response with statistics information, confirming the Token is valid.