Google URL Shortener API Integration With Node.js

Google URL Shortener at goo.gl is a service that takes long URLs and squeezes them into fewer characters to make a link that is easier to share, tweet, or email to friends. Users can create these short links through the web interface at goo.gl, or they can programatically create them through the Google URL Shortener API. With the URL Shortener API you can write applications that use simple HTTP methods to create, inspect, and manage goo.gl short links from desktop, mobile, or web.

Here are list of Google URL Shortener API methods that can be used in our applications,

  • get – Expands a short URL or gets creation time and analytics.
  • insert – Creates a new short URL.
  • list – Retrieves a list of URLs shortened by a user.

Methods :

  • url.get method gets expansion information for a specified short URL. For the given short URL, the url.get method returns the corresponding long URL and the status.
  • url.insert method creates a new short URL. Authentication is optional for the url.insert method. If an authentication token with access to https://www.googleapis.com/auth/urlshortener is provided, the method creates a short URL for the authenticated user. The short URL created will appear in the authenticated user’s list method results and on their dashboard at http://goo.gl/. If no authentication is provided, the short URL that the method creates is not associated with any particular account.
  • url.list method retrieves a list of URLs shortened by the authenticated user. The url.list method returns a paginated list of information about short URLs created by a user, sorted in reverse chronological order. Each returned resource contains the short URL, long URL, creation timestamp, and status.

Source Code :

We are using Google APIs Node.js Client and Express.js to demonstrate the programmatic methods of using Google URL Shortener. Each methods on the APIs is demonstrated with different routing.

Note : Please replace API keys, Client ID and Client Secret with your application details.

Siva Sankar

SIVA SANKAR, Working as a Software Engineer, Blogging is my hobby. I completed my Bachelors of Engineering (Computer Science Engineering) in Chennai, India. and my Master of Engineering (Embedded System Technologies) in Tamilnadu, India.

One thought on “Google URL Shortener API Integration With Node.js

  1. Hi everyone, it’s my first go to see at this web page, and piece of writing is actually fruitful
    in favor of me, keep up posting these types of articles or reviews.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.