npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ryb73/bs-google-apis

v0.6.1

Published

Bucklescript bindings for Google REST Apis

Downloads

45

Readme

bs-google-apis

What is it?

A Bucklescript implementation of various Google REST APIs.

What state is it in?

Very incomplete, unstable API. The published version may lag behind the GitHub repo – feel free to file a bug if this is the case.

How do I install it?

npm i @ryb73/bs-google-apis

How do I use it?

Auth

More info:

https://developers.google.com/identity/protocols/OAuth2UserAgent https://developers.google.com/identity/protocols/OpenIDConnect

getAuthUrl

Builds a URL to which you can redirect the user to begin the client-side OAuth2 flow.

let getAuthUrl:
    (~state: string=?, ~accessType: accessType=?, ~prompt: prompt=?, string,
    Js.Array.t(scope), string, responseType) => string;

GoogleApis.Auth.getAuthUrl(
    ~state="<STATE>", clientId, [| YouTube |],
    "https://my.app/", Code);
/* https://accounts.google.com/o/oauth2/v2/auth?client_id=<CLIENT_ID>&redirect_uri=https%3A%2F%2Fmy.app%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube&response_type=code&state=<STATE> */

getTokensFromCode

Retrieves access and refresh tokens given an OAuth2 code.

type tokens = {
    access_token: string,
    refresh_token: option(string),
    expires_in: int,
};

let getTokensFromCode:
    (~accessType: accessType=?, string, string, string, string) =>
    Js.Promise.t(tokens);

GoogleApis.Auth.getTokensFromCode("<client id>", "<client secret>", code, "https://my.app/");

getTokensForServiceAccount

Retrieve access and refresh tokens for a service account.

let getTokensForServiceAccount:
    (Js.Array.t(scope), string, string) => Js.Promise.t(tokens);

GoogleApis.Auth.getTokensForServiceAccount([| Profile |], "[email protected]", "<private key>");

refreshAccessToken

let refreshAccessToken:
    (string, string, string) => Js.Promise.t(tokens);

GoogleApis.Auth.refreshAccessToken(clientId, secret, refreshToken);

People

More info: https://developers.google.com/people/api/rest/v1/people

getMe

type name = { displayName: string, };
type t = {
    resourceName: string,
    etag: string,
    names: option(array(name)),
};

let getMe: (string, Js.Array.t(field)) => Js.Promise.t(t);

GoogleApis.People.getMe(accessToken, [| Names |]);

YouTube

More info: https://developers.google.com/youtube/v3/docs/

In this section you can assume open GoogleApis.YouTube is included.

parts

Represents the parts of the resource that are being requested. The parts are typed such that the type of the response you get from an API call will match the parts that you pass in.

let parts = PlaylistItems.(parts |> withSnippet);
PlaylistItems.listByPlaylistId(~parts, ~playlistId, accessToken);
/*
    {
        ...,
        items: [|
            ...,
            {
                id: "playlistitem123",
                contentDetails: (), /* `contentDetails` is typed as unit because `withContentDetails` was omitted */
                snippet: { /* while `snippet` is typed with the actual response data */
                    channelId: string,
                    channelTitle: string,
                    title: string,
                    description: string,
                    playlistId: string,
                    position: int,
                }
            }
        |]
    }
*/

Types

type pageInfo = {
    resultsPerPage: int,
    totalResults: int,
};

type result('item) = {
    items: array('item),
    nextPageToken: option(string),
    prevPageToken: option(string),
    pageInfo: pageInfo,
};

PlaylistItems

listByPlaylistId
let listByPlaylistId:
    (~maxResults: int=?, ~pageToken: string=?,
     ~parts: parts('a, 'b), ~playlistId: string, string)
    => Js.Promise.t(List.result('a, 'b));

/* (see `parts` section above for example usage) */

Playlists

listById
let listById:
    (~maxResults: int=?, ~parts: parts('a, 'b), ~ids: Js.Array.t(id),
    string) => Js.Promise.t(List.result('a, 'b));

Playlists.listById(~parts, ~ids=[|"<playlist ID>"|], accessToken);
listMine

List the authenticated user's playlists.

let listMine:
    (~maxResults: int=?, ~pageToken: string=?, ~parts: parts('a, 'b), string) =>
    Js.Promise.t(List.result('a, 'b));

Playlists.listMine(~parts, accessToken);

Search

list
let list:
    (~maxResults: int=?, ~pageToken: string=?, ~query: string, string) =>
    Js.Promise.t(List.result);

Search.list(~query, accessToken);

Videos

listById
let listById:
    (~maxResults: int=?, ~pageToken: string=?, ~parts: parts('a, 'b),
     ~ids: Js.Array.t(id), string) => Js.Promise.t(List.result('a, 'b));

Videos.listById(~parts, ~ids=[|"<video ID>"|], accessToken);