Skip to content
This repository has been archived by the owner on Mar 3, 2021. It is now read-only.

New API List

Chun-Hao Lien edited this page Sep 30, 2018 · 17 revisions

New Pixiv API List

Welcome to use these API in your script or help me to enhance and complete this wiki

創用 CC 授權條款

Pre-define Struct

BasicResponseFormat

// return status code: 2xx
{
  error: false,
  message: "",
  body: null || [] || {...}
}
// Be careful, even error is false but body is null or empty array...
// We call this situation following: NullBodyResponse

// return status code: 4xx
{
  error: true,
  message: String, // non-empty string
  body: []
}

DynamicHTMLScriptURL

Return a script string that will call document.write

IdString

Return a string that is integer number greater than 0

TagString

Return a string that contains no space

BasicIllustData

{
  id: IdString,
  title: String,
  illustType: Number, // One of [0 ⇒ illust, 1 ⇒ manga, 2 ⇒ ugoira]
  xRestrict: Number, // One of [0 ⇒ General, 1 ⇒ R-18, 2 ⇒ R-18G]
  url: URLString,
  tags: TagString[],
  userId: IdString,
  width: Number,
  height: Number,
  pageCount: Number,
  isBookmarkable: Boolean,
  bookmarkData: null || {
    id: IdString,
    private: Boolean,
  },
}

TagDetailData

{
  tag: TagString,
  locked: Boolean,
  deletable: Boolean,
  userId: IdString,
  romaji: String,
  translation?:	{
    en: String,
  },
  userName: String,
}

PickupableData

{
  type: String, // One of ['fanbox', 'comikeWebCatalog', ???]
  title: String,
  url: URLString,
  description: String,
  imageUrl: URLString,
}

getUserData

  • url: /ajax/user/:user_id
  • method: GET

response

{
  error: Boolean,
  message: String,
  body: {
    userId: IdString,
    name: String,
    image: URLString,
    imageBig: URLString,
    premium: Boolean,
    isFollowed: Boolean,
    background: null || {
      repeat: String, // One of ["repeat-y", "repeat", "no-repeat"]
      color: null || ColorHexString, // [A-Z0-9]{6}
      url: URLString,
    },
    partial: Number,
  },
}

getUserIllustsData

  • url: /ajax/user/:user_id/illusts
  • method: GET
  • param: ?ids[]={{illust_id[0]}}&ids[]={{illust_id[1]}}&...
    • limit≧65
  • Has NullBodyResponse: []

response

{
  error: Boolean,
  message: String,
  body: {
    ...
    [illustId]: { isMuted: Boolean } extends BasicIllustData,
  },
}

getUserProfileData

response

{
  error: Boolean,
  message: String,
  body: {
    illusts: {
      ...
      [illustId]: BasicIllustData,
    }
    manga: {
      ...
      [illustId]: BasicIllustData,
    },
    novels: [], // ???
    mangaSeries: [] || {
      ...
      [mangaSeriesId]: {
        id: IdString,
        title: String,
        total: String, // but String of Number. why... pixiv why...
        url: URLString,
        updateDate: DateString, // format: "yyyy-mm-dd HH:MM:SS"
      },
    }
    pickup: PickupableData[],
    bookmarkCount: {
      public: {
        illust: Number,
        novel: Number
      },
      private: {
        illust: Number,
        novel: Number
      }
    },
    zoneConfig: {
      header: DynamicHTMLScriptURL,
      footer: DynamicHTMLScriptURL,
      logo: DynamicHTMLScriptURL,
    },
  },
}

getUserBookmarkTagsData

  • url: /ajax/user/:user_id/illusts/bookmark/tags
  • method: GET

response

{
  error: Boolean,
  message: String,
  body: {
    public: ({
      tag: String,
      cnt: String, // String of Number... why........
    })[],
    private: ({
      tag: String,
      cnt: String,
    })[],
    tooManyBookmark: Boolean, // ???
  },
}

getUserBookmarkData

  • url: /ajax/user/:user_id/illusts/bookmarks
  • method: GET
  • param: ?limit=&offset=&rest=&tag=
    • offset, limit: fetch count of limit data from offset
    • rest: show as public, hide as private
    • tag: TagString join with ,
  • Has NullBodyResponse: null

response

{
  error: Boolean,
  message: String,
  body: {
    works: ({ profileImgUrl: URLString } extends BasicIllustData)[],
    total: Number,
  },
}

getIllustBookmarkData

  • url: /ajax/illust/:illust_id/bookmarkData
  • method: GET

response

{
  error: Boolean,
  message: String,
  body: {
    illustId: IdString,
    isBookmarkable: Boolean,
    bookmarkData: null || {
      id: IdString,
      private: Boolean,
    },
  },
}

getIllustData

  • url: /ajax/illust/:illust_id
  • method: GET

response

{
  error: Boolean,
  message: String,
  body: {
    illustId: IdString,
    illustTitle: String,
    illustComment: String,
    id: IdString, // the same as illustId
    title: String, // the same as illustTitle
    description: String, // the same as illustComment
    illustType: Number, // One of [0 ⇒ illust, 1 ⇒ manga, 2 ⇒ ugoira]
    createDate: DateString, // format: "yyyy-mm-ddTHH:MM:SS+00:00" (like Date.prototypr.toISOString but no Z)
    uploadDate: DateString,
    restrict: Number, // ???
    xRestrict: Number, // One of [0 ⇒ General, 1 ⇒ R-18, 2 ⇒ R-18G]
    urls: {
      mini: URLString,
      thumb: URLString,
      small: URLString,
      regular: URLString,
      original: URLString,
    },
    tags: {
      authorId: IdString,
      isLocked: Boolean,
      tags: TagDetailData[],
      writable: Boolean
    },
    storableTags: HashString[],
    userId: IdString,
    userName: String,
    userAccount: String,
    userIllusts: {
      ...
      [illustId]: null || BasicIllustData,
    },
    likeData: Boolean, // Do you like this illust today
    likeCount: Number,
    width: Number,
    height: Number,
    pageCount: Number,
    bookmarkCount: Number,
    commentCount: Number,
    responseCount: Number,
    viewCount: Number,
    isHowto: Boolean,
    isOriginal: Boolean,
    imageResponseOutData: [],
    imageResponseData: [],
    imageResponseCount: Number,
    pollData: null, // ???
    seriesNavData: null || {
      seriesType: String, // One of ["manga", ???]
      seriesId: IdString,
      title: String,
      order: Number,
      prev: {
        id: IdString,
        title: String,
        order: Number,
      },
      next: {
        id: IdString,
        title: String,
        order: Number,
      },
    },
    descriptionBoothId: null, // ???
    comicPromotion: null, // ???
    contestBanners: [], // ???
    factoryGoods: {
      integratable: Boolean,
      integrated: Boolean,
    },
    isBookmarkable: Boolean,
    bookmarkData: {
      id: IdString,
      private: Boolean,
    },
    zoneConfig: {
      responsive: {
        url: DynamicHTMLScriptURL
      },
      "300x250": {
        url: DynamicHTMLScriptURL
      },
      "500x500": {
        url: DynamicHTMLScriptURL
      },
      header: {
        url: DynamicHTMLScriptURL
      },
      footer: {
        url: DynamicHTMLScriptURL
      },
      logo: {
        url: DynamicHTMLScriptURL
      },
    },
  },
}

getIllustUgoiraMeta

  • url: /ajax/illust/:illust_id/ugoira_meta
  • method: GET

response

{
  error: Boolean,
  message: String,
  body: {
    src: URLString,
    originalSrc: URLString,
    mime_type: MIMEString, // One of ["image/jpeg", ???]
    frames: ({ file: ImageFileString, delay: Number })[],
  },
}

postIllustLike

ref: Pixiv Auto Like

  • url: /ajax/illusts/like

  • method: POST

  • headers:

    • Content-Type: application/json
    • x-csrf-token: globalInitData.token
  • credentials: same-origin // with cookie

  • body: JSON.stringify following object

    {
      "illust_id": IdString,
    }

response

{
  error: Boolean,
  message: String,
  body: {
    is_liked: Boolean,
  },
}

postAddBookmark

  • url: /ajax/illusts/bookmarks/add

  • method: POST

  • headers:

    • Content-Type: application/json
    • x-csrf-token: globalInitData.token
  • credentials: same-origin // with cookie

  • body: JSON.stringify following object

    {
      "comment": String,
      "illust_id": IdString,
      "restrict": Number, // 0 ⇒ public, 1 ⇒ private
      "tags": TagString[],
    }

response

{
  error: Boolean,
  message: String,
  body: {
    last_bookmark_id: IdString,
    stacc_status_id: IdString,
  },
}

postRPCDeleteBookmark / postRPCAddBookmark

These are NOT new API but used in Patchouli.

ref: Pixiv 一鍵收藏 EX

  • url: /rpc/index.php

  • method: POST

  • headers:

    • Content-Type: application/x-www-form-urlencoded
  • credentials: same-origin // with cookie

  • body:

    • delete: following parameter concat as application/x-www-form-urlencoded format
    parameter value
    mode "delete_illust_bookmark"
    bookmark_id IdString
    • add: following parameter concat as application/x-www-form-urlencoded format
    parameter value
    mode "save_illust_bookmark"
    illust_id IdString
    restrict 0 (public) or 1 (private)
    comment String
    tags TagString[].join(',')
    tt login token

response

{
  error: Boolean,
  message: String,
  body: [],
}