Closed zaytri closed 7 months ago
from Alejo:
TL;DR: new API's users/ endpoint comes as an object instead of an array and adds a new field called alt_pronoun_id, which is the 2nd set of pronouns users will be able to pick
The endpoints you are gonna care about are: GET https://api.pronouns.alejo.io/v1/pronouns GET https://api.pronouns.alejo.io/v1/users/USERNAME
Oh, one more thing, new pronouns endpoint has more fields than just name and display. New structure is { name: string, subject: string, object: string, singular: boolean }, if singular is true then you just need to render the Subject, this is for cases like "Other" or "Any" that don't have proper subject/obejct form, so you'd just render them as Any instead of Any/Any
Changes between the old users API
GET https://pronouns.alejo.io/api/users/USERNAME
and the new users API
GET https://api.pronouns.alejo.io/v1/users/USERNAME
Old | New | |
---|---|---|
No pronouns set | Empty array | Error 404 |
Pronouns set | Array with a single user object | Just the user object (no longer wrapped in an array) |
Old user object structure:
type User = {
id: string // Twitch ID
login: string // Twitch username
pronoun_id: string // maps to the corresponding ID from the pronouns endpoint
}
New user object structure:
type User = {
channel_id: string // Twitch ID
channel_login: string // Twitch username
pronoun_id: string // maps to the corresponding ID from the pronouns endpoint
alt_pronoun_id?: string // same as above for secondary pronoun, optional (can be null)
}
Changes between the old pronouns API
GET https://pronouns.alejo.io/api/pronouns
and the new pronouns API
GET https://api.pronouns.alejo.io/v1/pronouns
Old:
type Pronouns = Data[]
type Data = {
name: string // maps to pronoun_id in the users API
display: string // pronouns display, for example "She/Her"
}
New:
// now an object instead of an array, where each key corresponds to a Data object
type Pronouns = {
[id: string]: Data // id = name
}
// display is now split into subject and object
type Data = {
name: string // maps to pronoun_id and alt_pronoun_id in the users API
subject: string // for "She/Her", this is "She"
object: string // for "She/Her", this is "Her"
/**
* if this is true,
* and the user has this as their pronoun_id,
* and has no alt_pronoun_id,
* then only display the subject (for example "Any" instead of "Any/Any")
*/
singular: boolean
}
Alejo updated the pronouns API to allow for reordering of pronouns, so I'll add this into the v1.2 update