Skip to content

Obtaining the PIXIVFE_TOKEN cookie

This guide covers how to obtain the PIXIVFE_TOKEN cookie from your Pixiv account, which is necessary for authenticating with the Pixiv API.

Warning

You should create an entirely new account for this to avoid account theft. And also, PixivFE will get contents from your account. You might not want people to know what kind of illustrations you like :P

For now, the only page that may contain contents that is relevant to you is the discovery page. Be careful if you are using your main account.

1. Log in to Pixiv

Log in to the Pixiv account you want to use. Upon logging in, you should see the Pixiv landing page. If you are already logged in, simply navigate to the landing page.

The URL of the landing page

2. Open developer tools

For Firefox

Press F12 to open the Firefox Developer Tools. Switch to the Storage tab.

Storage tab on Firefox

For Chrome

Press F12 to open the Chrome Developer Tools. Switch to the Application tab.

Application tab on Chrome

For Firefox

In the left sidebar, expand the Cookies section and select www.pixiv.net. This is where you will find your authentication cookie.

Locate the cookie with the key PHPSESSID. The value next to this key is your account's token.

Cookie on Firefox

For Chrome

In the left sidebar, find the Storage section. Expand the Cookies subsection and select www.pixiv.net. This is where you will find your authentication cookie.

Locate the cookie with the key PHPSESSID. The value next to this key is your account's token.

PHPSESSID on Chrome-based browsers

4. Set the environment variable

Copy the token value obtained in the previous step. If deploying with Docker, set it as the PIXIVFE_TOKEN environment variable in your configuration.

5. Configuring account settings (optional)

To ensure PixivFE works as intended, your Pixiv account should have the following settings configured:

  • Japan as account region
  • R-18G content visible
  • AI-generated works visible

You can adjust these settings either by:

  • Configuring them manually in your account settings.
  • Running the provided prepare-account.sh script to configure them automatically.

Automated configuration

The prepare-account.sh shell script is located in the doc/hosting directory of the PixivFE repository. To use it, run the script and pass your PHPSESSID as an argument:

Bash
./prepare-account.sh YOUR_PHPSESSID

Manual configuration

To manually configure the recommended settings:

  1. Navigate to Pixiv's display settings page.
  2. Adjust the following settings:
    • Enable "Show ero-guro content (R-18G)" if desired
    • Configure any other display preferences as needed

To verify the R-18G content visibility setting was applied:

  1. Visit the gore search endpoint.
  2. Look for "R-18G" tags in the returned results.
  3. If you disable the R-18G option and search again, R-18G artworks should no longer appear in the results.

Using multiple tokens

Warning

If you maintain a public PixivFE instance, it is recommended to use multiple tokens, each sourced from a different Pixiv account.

Pixiv enforces limitations on server load to prevent excessive usage, and using a single account for a high volume of requests can lead to account suspension or termination.

To mitigate this risk:

  1. Create multiple Pixiv accounts, each with its own PIXIVFE_TOKEN.
  2. Specify multiple tokens in the PIXIVFE_TOKEN environment variable, separating them with commas.

Spreading requests across multiple accounts reduces the load on any single account, reducing the risk of triggering Pixiv's anti-abuse measures and allowing for a higher overall request volume.

If one account is temporarily restricted or suspended, your instance can continue using the other accounts.

Additional notes

  • The token looks like this: 123456_AaBbccDDeeFFggHHIiJjkkllmMnnooPP
    • The underscore separates your member ID (left side) from a random string (right side)
  • Logging out of Pixiv will reset the token. Always verify your token is current before reporting issues.
  • Guides for Chrome was taken from Nandaka's guide on logging in with cookies.