Script integration with Medium.com. This object handles OAuth authentication and request signing. The entire Medium REST API can be used with the request method, and convenience methods are provided for common API endpoints to get user information, list publications and post.

If an API calls fails, typically the result will be an undefined value, and the lastError property will contains error detail information for troubleshooting.

Hierarchy

  • Medium

Constructors

  • Create new instance.

    Parameters

    • Optional identifier: string

    Returns Medium

Properties

lastError?: string

If a function fails, this property will contain the last error as a string message, otherwise it will be undefined.

lastResponse: any

If a function success, this property will contain the last response returned by Medium. The JSON returned by Medium will be parsed to an object and placed in this property. Refer to Medium API documentation for details on the contents of this object based on call made.

Methods

  • Create a post in the user's Medium stories. See API docs for details on what should be included in the options.

    Parameters

    • userId: string
    • options: object

    Returns object

  • Get User information for current authenticated user. This will include the id property needed for other calls.

    Returns object

  • Get list of publications for current authenticated user.

    Parameters

    • userId: string

    Returns object[]

  • Execute a request against the Medium API. For successful requests, the HTTPResponse object will contain an object or array or objects decoded from the JSON returned by Medium as appropriate to the request made. Refer to Medium API documentation for details about the expected parameters and responses. Drafts will handle wrapping the request in the appropriate OAuth authentication flow.

    Parameters

    • settings: {
          data?: {
              [x: string]: string;
          };
          headers?: {
              [x: string]: string;
          };
          method: string;
          parameters?: {
              [x: string]: string;
          };
          url: string;
      }

      an object configuring the request.

      • Optional data?: {
            [x: string]: string;
        }

        A JavaScript object containing data to be encoded into the HTTP body of the request.

        • [x: string]: string
      • Optional headers?: {
            [x: string]: string;
        }

        An object contain key-values to be added as custom headers in the request. There is no need to provide authorization headers, Drafts will add those.

        • [x: string]: string
      • method: string

        The HTTP method, like "GET", "POST", etc.

      • Optional parameters?: {
            [x: string]: string;
        }

        An object containing key-values to be added to the request as URL parameters.

        • [x: string]: string
      • url: string

        The full URL to the endpoint in the Medium REST API.

    Returns HTTPResponse

  • Creates a new Medium object.

    Parameters

    • identifier: string

      Optional string value used to identify a Medium account. Typically this can be omitted if you only work with one Medium account in Drafts. Each unique identifier used for Medium accounts will share credentials - across both action steps and scripts.

    Returns any

Generated using TypeDoc