openapi: 3.0.0
info:
  title: Facebook Profile Photos API
  description: |
    The Facebook Profile Photos API returns the photos a public Facebook profile or Page has posted, newest
    first, eight at a time, with the image link and size, a thumbnail, Facebook's description of the picture
    and the photo's own page.

    The first page adds a `profile` block. Each response carries a `pagination.next_page_token` while more
    photos remain. Pass it back as `next_page_token` to fetch the next page. The token identifies the profile
    on its own, so `url` may be omitted with it.

    A profile Facebook does not show publicly, a share link that opens something other than a profile, a
    profile without public photos and a `next_page_token` Facebook no longer accepts answer 200 with an
    `error` and cost a credit.

    **Cross-linking**: `post.author.link` from the Facebook Post API and `page.link` from the Facebook Business
    Page API are valid `url` values here. A photo's `link` is a valid `url` for the Facebook Post and Facebook
    Comments APIs.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Facebook Profile Photos
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine identifier
          schema:
            type: string
            enum: ["facebook_profile_photos"]
            default: "facebook_profile_photos"
        - name: url
          in: query
          required: false
          description: >-
            Link of the public Facebook profile or Page, such as https://www.facebook.com/NASA. profile.php,
            people, numeric id and share links are accepted, and so is the link of one of the profile's tabs.
            Required unless next_page_token is provided.
          schema:
            type: string
            maxLength: 2048
        - name: next_page_token
          in: query
          required: false
          description: >-
            Cursor for the next page, from pagination.next_page_token in a previous response. Omit it for the
            first page.
          schema:
            type: string
            maxLength: 8192
      responses:
        '200':
          description: >-
            Successful response. When Facebook shows no such profile publicly, the profile has no public photos,
            or Facebook no longer accepts the next_page_token, the body carries `error` naming the reason in place
            of `photos`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '400':
          description: >-
            Validation Error. There is an issue with query parameters, such as a link that is not a Facebook
            profile or Page, or a next_page_token that is malformed or belongs to another profile. The search is
            not billed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication Error. The API key is missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate Limit Exceeded. The number of allowed requests has been exceeded. Consider upgrading your plan or waiting for the limit to reset.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server Error. Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Timeout, or Facebook answered but returned nothing usable. The search is not billed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: 'Use Bearer authentication. Format: "Bearer YOUR_API_KEY"'
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api_key
      description: Pass API key as query parameter
  schemas:
    SearchResponse:
      type: object
      properties:
        search_metadata:
          $ref: '#/components/schemas/SearchMetadata'
        search_parameters:
          $ref: '#/components/schemas/SearchParameters'
        profile:
          $ref: '#/components/schemas/Profile'
        photos:
          type: array
          description: Photos of the profile for this page
          items:
            $ref: '#/components/schemas/Photo'
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Message naming why there are no photos to show
    Profile:
      type: object
      description: The profile or Page whose photos are listed
      required: [id, name, link, avatar, is_verified]
      properties:
        id:
          type: string
          description: Facebook id of the profile
        name:
          type: string
          description: Display name of the profile
        username:
          type: string
          description: Username in the profile's link
        link:
          type: string
          format: uri
          description: URL of the profile on Facebook
        avatar:
          type: string
          format: uri
          description: URL of the profile picture
        is_verified:
          type: boolean
          description: Whether the profile is verified
        followers:
          $ref: '#/components/schemas/SocialMetric'
        cover_photo_original:
          type: string
          format: uri
          description: URL of the profile's cover photo image file
        cover_photo_link:
          type: string
          format: uri
          description: Facebook URL of the cover photo post
    SocialMetric:
      type: object
      description: The follower count Facebook shows, with the link to the list
      required: [text]
      properties:
        text:
          type: string
          description: Count as Facebook shows it, such as 28M followers
        link:
          type: string
          format: uri
          description: Facebook URL listing the followers
        count:
          type: integer
          description: Count as a number, rounded as Facebook shows it
    Photo:
      type: object
      required: [position, id, link, image, width, height, thumbnail]
      properties:
        position:
          type: integer
          description: Position of the photo on this page, starting at 1
        id:
          type: string
          description: Numeric id of the photo
        link:
          type: string
          format: uri
          description: URL of the photo on Facebook
        image:
          type: string
          format: uri
          description: URL of the largest image file Facebook offers
        width:
          type: integer
          description: Width of the image in pixels
        height:
          type: integer
          description: Height of the image in pixels
        accessibility_caption:
          type: string
          description: Facebook's description of the picture, or its note that there is none
        thumbnail:
          type: string
          format: uri
          description: URL of a smaller version of the image
    Pagination:
      type: object
      properties:
        next_page_token:
          type: string
          description: Cursor for the next page of the same list
    SearchMetadata:
      type: object
      required: [status, created_at]
      properties:
        id:
          type: string
          description: Unique identifier for the search request, absent when zero_retention is set
        status:
          type: string
          description: Status of the search request
        created_at:
          type: string
          format: date-time
          description: Timestamp when the search was created
        request_time_taken:
          type: number
          description: Time taken to make the request in seconds
        parsing_time_taken:
          type: number
          description: Time taken to parse the results in seconds
        total_time_taken:
          type: number
          description: Total time taken for the search in seconds
        request_url:
          type: string
          description: Facebook URL of the requested profile
        html_url:
          type: string
          description: URL to view HTML results
        json_url:
          type: string
          description: URL to view JSON results
    SearchParameters:
      type: object
      required: [engine]
      properties:
        engine:
          type: string
          description: Search engine identifier
        url:
          type: string
          description: Profile link the photos were requested with
        next_page_token:
          type: string
          description: Cursor of the requested page
        zero_retention:
          type: boolean
          description: Whether zero data retention was requested
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
