Apache
ballerinax/Apache Ballerina library
Overview
Ballerina connector for Giphy is connecting the Giphy API via Ballerina language easily. It provides functions to get GIFs and stickers.
This module supports Giphy API version 1.
Prerequisites
Before using this connector in your Ballerina application, complete the following:
- Create Giphy account
- Obtain tokens - Follow this link
Quickstart
To use the Giphy connector in your Ballerina application, update the .bal file as follows:
Step 1: Import Giphy module
First, import the ballerinax/giphy module into the Ballerina project.
import ballerinax/giphy;
Step 2: Initialize Giphy client
You can now make the connection configuration using the Giphy API keys config.
giphy:ApiKeysConfig configuration = <API_KEY_PAIR> giphy:Client giphyClient = check new (configuration);
Step 3: Create get a random GIF operation
Following is code demonstrates how to get a random GIF using ballerinax/giphy
connector.
public function main() returns error? { giphy:Response entity = check giphyClient->randomGif(); }
Clients
Apache: Client
Giphy API
Constructor
Client initialization.
init (ApiKeysConfig apiKeyConfig, ClientConfiguration clientConfig, string serviceUrl)
- apiKeyConfig ApiKeysConfig - API key configuration detail
- clientConfig ClientConfiguration {} - Client configuration details
- serviceUrl string "https://api.giphy.com/v1" - Connector server URL
getGifsById
function getGifsById(string? ids) returns PaginatedResponse|error
Get GIFs by ID
Parameters
- ids string? (default ()) - Filters results by specified GIF IDs, separated by commas.
Return Type
- PaginatedResponse|error - GIF or an error
randomGif
Random GIF
Parameters
- tag string? (default ()) - Filters results by specified tag.
- rating string? (default ()) - Filters results by specified rating.
searchGifs
function searchGifs(string q, int? 'limit, int? offset, string? rating, string? lang) returns PaginatedResponse|error
Search GIFs
Parameters
- q string - Search query term or prhase.
- 'limit int? (default 25) - The maximum number of records to return.
- offset int? (default 0) - An optional results offset.
- rating string? (default ()) - Filters results by specified rating.
- lang string? (default ()) - Specify default language for regional content; use a 2-letter ISO 639-1 language code.
Return Type
- PaginatedResponse|error - GIFs or an error
translateGif
Translate phrase to GIF
Parameters
- s string - Search term.
trendingGifs
function trendingGifs(int? 'limit, int? offset, string? rating) returns PaginatedResponse|error
Trending GIFs
Parameters
- 'limit int? (default 25) - The maximum number of records to return.
- offset int? (default 0) - An optional results offset.
- rating string? (default ()) - Filters results by specified rating.
Return Type
- PaginatedResponse|error - Treading GIFs or an error
getGifById
Get GIF by Id
Parameters
- gifId int - Filters results by specified GIF ID.
randomSticker
Random Sticker
Parameters
- tag string? (default ()) - Filters results by specified tag.
- rating string? (default ()) - Filters results by specified rating.
searchStickers
function searchStickers(string q, int? 'limit, int? offset, string? rating, string? lang) returns PaginatedResponse|error
Search Stickers
Parameters
- q string - Search query term or prhase.
- 'limit int? (default 25) - The maximum number of records to return.
- offset int? (default 0) - An optional results offset.
- rating string? (default ()) - Filters results by specified rating.
- lang string? (default ()) - Specify default language for regional content; use a 2-letter ISO 639-1 language code.
Return Type
- PaginatedResponse|error - Stickers or an error
translateSticker
Translate phrase to Sticker
Parameters
- s string - Search term.
trendingStickers
function trendingStickers(int? 'limit, int? offset, string? rating) returns PaginatedResponse|error
Trending Stickers
Parameters
- 'limit int? (default 25) - The maximum number of records to return.
- offset int? (default 0) - An optional results offset.
- rating string? (default ()) - Filters results by specified rating.
Return Type
- PaginatedResponse|error - Treading stickers or an error
Records
Apache: ApiKeysConfig
API key configuration.
Fields
Apache: Gif
Fields
- bitly_url string? - The unique bit.ly URL for this GIF
- content_url string? - Currently unused
- create_datetime string? - The date this GIF was added to the GIPHY database.
- embded_url string? - A URL used for embedding this GIF
- featured_tags string[]? - An array of featured tags for this GIF (Note: Not available when using the Public Beta Key)
- id string? - This GIF's unique ID
- images GifImages? -
- import_datetime string? - The creation or upload date from this GIF's source.
- rating string? - The MPAA-style rating for this content. Examples include Y, G, PG, PG-13 and R
- slug string? - The unique slug used in this GIF's URL
- 'source string? - The page on which this GIF was found
- source_post_url string? - The URL of the webpage on which this GIF was found.
- source_tld string? - The top level domain of the source URL.
- tags string[]? - An array of tags for this GIF (Note: Not available when using the Public Beta Key)
- trending_datetime string? - The date on which this gif was marked trending, if applicable.
- 'type string? - Type of the gif. By default, this is almost always gif
- update_datetime string? - The date on which this GIF was last updated.
- url string? - The unique URL for this GIF
- user User? - The User Object contains information about the user associated with a GIF and URLs to assets such as that user's avatar image, profile, and more.
- username string? - The username this GIF is attached to, if applicable
Apache: GifImages
Fields
- downsized record {*Image;} ? -
- downsized_large record {*Image;} ? -
- downsized_medium record {*Image;} ? -
- downsized_small record {*Image;} ? -
- downsized_still record {*Image;} ? -
- fixed_height record {*Image;} ? -
- fixed_height_downsampled record {*Image;} ? -
- fixed_height_small record {*Image;} ? -
- fixed_height_small_still record {*Image;} ? -
- fixed_height_still record {*Image;} ? -
- fixed_width record {*Image;} ? -
- fixed_width_downsampled record {*Image;} ? -
- fixed_width_small record {*Image;} ? -
- fixed_width_small_still record {*Image;} ? -
- fixed_width_still record {*Image;} ? -
- looping record {*Image;} ? -
- original record {*Image;} ? -
- original_still record {*Image;} ? -
- preview record {*Image;} ? -
- preview_gif record {*Image;} ? -
Apache: Image
Fields
- frames string? - The number of frames in this GIF.
- height string? - The height of this GIF in pixels.
- mp4 string? - The URL for this GIF in .MP4 format.
- mp4_size string? - The size in bytes of the .MP4 file corresponding to this GIF.
- size string? - The size of this GIF in bytes.
- url string? - The publicly-accessible direct URL for this GIF.
- webp string? - The URL for this GIF in .webp format.
- webp_size string? - The size in bytes of the .webp file corresponding to this GIF.
- width string? - The width of this GIF in pixels.
Apache: Meta
The Meta Object contains basic information regarding the request, whether it was successful, and the response given by the API. Check responses
to see a description of types of response codes the API might give you under different cirumstances.
Fields
- msg string? - HTTP Response Message
- response_id string? - A unique ID paired with this response from the API.
- status int? - HTTP Response Code
Apache: PaginatedResponse
Fields
- data Gif[]? -
- meta Meta? - The Meta Object contains basic information regarding the request, whether it was successful, and the response given by the API. Check
responses
to see a description of types of response codes the API might give you under different cirumstances.
- pagination Pagination? - The Pagination Object contains information relating to the number of total results available as well as the number of results fetched and their relative positions.
Apache: Pagination
The Pagination Object contains information relating to the number of total results available as well as the number of results fetched and their relative positions.
Fields
- count int? - Total number of items returned.
- offset int? - Position in pagination.
- total_count int? - Total number of items available.
Apache: Response
Fields
- data Gif? -
- meta Meta? - The Meta Object contains basic information regarding the request, whether it was successful, and the response given by the API. Check
responses
to see a description of types of response codes the API might give you under different cirumstances.
Apache: User
The User Object contains information about the user associated with a GIF and URLs to assets such as that user's avatar image, profile, and more.
Fields
- avatar_url string? - The URL for this user's avatar image.
- banner_url string? - The URL for the banner image that appears atop this user's profile page.
- display_name string? - The display name associated with this user (contains formatting the base username might not).
- profile_url string? - The URL for this user's profile.
- twitter string? - The Twitter username associated with this user, if applicable.
- username string? - The username associated with this user.
Import
import ballerinax/Apache;
Metadata
Released date: over 3 years ago
Version: 0.1.0
License: Apache-2.0
Compatibility
Platform: any
Ballerina version: slalpha5
GraalVM compatible: Yes
Pull count
Total: 1
Current verison: 1
Weekly downloads
Keywords
giphy
GIF
sticker
Contributors
Other versions
0.1.0
Dependencies