Nirvana

## What is Nirvana?

Nirvana is a MVC application framework which consists of controllers and methods (also known as templates). It can be accessed via the /wikia.php or /api/v1 endpoint on every wiki for on-wiki things. There is also a central Fandom REST API which takes care of more global things (like notifications) which can be accessed at services.fandom.com.

## Controllers

Here is a list of controllers and templates I have been able to find. Most controllers do not have a HTML format, so they will need to have format=json in the request parameters.

The general layout for wikia.php URLs is https://WIKI.fandom.com/wikia.php?controller=CONTROLLER&method=METHOD&format=FORMAT&PARAMETERS. Any additional parameters can be added on the end.

For api/v1 URLs, https://WIKI.fandom.com/api/v1/CONTROLLER/METHOD/?PARAMETERS, and additional parameters are added on the end.

Finally, for Fandom services, https://services.fandom.com/SERVICE/ROUTES/ but there are multiple ways parameters are inputted.

Wikia.php controllers can also have their name suffixed by "Controller" which has no effect on their usage.

## Logging in for feeds

### `/kratos-public/self-service/login/api`

GET `https://services.fandom.com/kratos-public/self-service/login/api` (doc) to initiate a login flow.

POST to the URL found in `ui.action` (doc) with a payload like this:

```
{
 "method": "password",
 "password\_identifier": username,
 "password": password
}

```

A `fandom_session` cookie is set automatically, which is used for authentication. The endpoint will also return a JSON body with information about the authentication and identity.

### `/mobile-fandom-app/fandom-auth/login`

POST the username and password in a `x-www-form-urlencoded` payload to `https://services.fandom.com/mobile-fandom-app/fandom-auth/login`. The password used for authentication on Discussions must be the regular account password (not from Special:BotPasswords)

A `fandom_session` cookie is set automatically, which is used for authentication. The endpoint will also return a JSON body with an `access_token` key and other authentication parameters. Using an `access_token` is deprecated.

### `/auth/token` (removed)

POST the username and password in a `x-www-form-urlencoded` payload to `https://services.fandom.com/auth/token`. The password used for authentication on Discussions must be the regular account password (not from Special:BotPasswords)
Set the `X-Wikia-WikiaAppsId` header to any integer to bypass the "proof of work" restriction that Fandom uses to deter denial-of-service attacks from occurring over the API. It's not publicly documented, but must be present for API scripts to work.

You may need to set the `X-Fandom-Auth` header to `1` on subsequent requests.
## Other headers

`X-Mw-Wiki-Id`
(wiki id integer) uses a different wiki then the one it was called from
## JSON post model

Fandom's Feeds messages are stored in their backend as a very limited subset of Atlassian Document Format (ADF).

 content
Each object in the array is a new line

### Block objects

#### Paragraph

 content
Different formatted objects are stringed together on one line, no spaces are added automatically

#### Open graph

 attrs.attachment
 attrs.wasAddedWithInlineLink

### Inline objects

##### Marks

###### Link

 attrs.href
 attrs.title

###### @Mention

 attrs.href
 attrs.userId
 attrs.userName

#### Image

 attrs.src
 attrs.alt
 attrs.title

## Thread source

String, can be any of the below:

* DISCUSSIONS
* CURATION\_CMS
* MOBILE\_APP\_ARTICLES
* MOBILE\_APP\_VIDEOS
* MOBILE\_APP\_FEED
* DESKTOP\_WEB\_DISCUSSIONS
* MOBILE\_WEB\_DISCUSSIONS
* MIGRATED\_POST
* CONSOLIDATED\_APP\_ANDROID
* CONSOLIDATED\_APP\_IOS
* COMMUNITY\_APP\_IOS
* UNCATEGORIZED
* COMMUNITY\_APP\_ANDROID
* DESKTOP\_WEB\_FEPO
* MOBILE\_WEB\_FEPO
* IOS\_APP\_FEPO
* ANDROID\_APP\_FEPO
* MIGRATED\_WALL\_POST
* MIGRATED\_ARTICLE\_COMMENT

## Social container types

* ARTICLE\_COMMENT
* WALL
* FORUM

## See also

* w:c:dev:User:KockaAdmiralac/Service API: some documentation on the Service API (services.fandom.com) endpoints
* w:c:elderscrolls:User:Atvelonis/Bot/Discussions API: some documentation on the Discussions API with examples in Python
* w:c:dev:Nirvana: info on the Dev Wiki