Skip to main content

a better python GIPHY client

Project description

test Documentation Status codecov License: MIT Code style: black Imports: isort

giphpy

giphpy was written to be a hand-spun alternative to the existing GIPHY client.

You should use it because:

  • it uses pydantic for lightning fast data serialization
  • it uses httpx to provide both a sync and async api

Installation

pip install giphpy

or for poetry

poetry add giphpy

Help

See the documentation for more details.

Example

giphpy is extremely easy to use. By setting serialize=True, you get a pydantic model returned to you instead of a httpx.Response object.

Example:

import giphpy

gif = giphpy.gif_translate("spongebob", api_key="xxx", serialize=True)
print(gif)

This will return a GifResponse object:

GifResponse(
        data=Gif(
            type='gif',
            id='o6TTJ6ak4A97a',
            url='https://giphy.com/gifs/spongebob-squarepants-squidward-nose-o6TTJ6ak4A97a',
            slug='spongebob-squarepants-squidward-nose-o6TTJ6ak4A97a',
            bitly_gif_url='http://gph.is/YBiYub',
            bitly_url='http://gph.is/YBiYub',
            embed_url='https://giphy.com/embed/o6TTJ6ak4A97a',
            username='spongebob',
            source='',
            title='Nose GIF by SpongeBob SquarePants',
            rating=<Rating.g: 'g'>,
            content_url='',
            source_tld='',
            source_post_url='',
            is_sticker=False,
            import_datetime=datetime.datetime(1970, 1, 1, 0, 0),
            trending_datetime=datetime.datetime(2017, 12, 21, 16, 0, 1),
            images=Images(
                downsized=DownsizedImage(
                    size='430185',
                    height='336',
                    width='500',
                    url=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/giphy.gif?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68'
                        'p60zymuq6950uz&rid=giphy.gif&ct=g'
                    ),
                ),
                downsized_large=DownsizedLargeImage(
                    size='430185',
                    height='336',
                    width='500',
                    url=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/giphy.gif?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68'
                        'p60zymuq6950uz&rid=giphy.gif&ct=g'
                    ),
                ),
                downsized_medium=DownsizedMediumImage(
                    size='430185',
                    height='336',
                    width='500',
                    url=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/giphy.gif?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68'
                        'p60zymuq6950uz&rid=giphy.gif&ct=g'
                    ),
                ),
                downsized_small=DownsizedSmallImage(
                    mp4_size='162356',
                    mp4=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/giphy-downsized-small.mp4?cid=9fbc9b3fgy0n3l2a9s'
                        'mslyf34wgd2s5z68p60zymuq6950uz&rid=giphy-downsized-small.mp4&ct=g'
                    ),
                    height='336',
                    width='500',
                ),
                downsized_still=DownsizedStillImage(
                    height='336',
                    width='500',
                    url=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/giphy_s.gif?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z'
                        '68p60zymuq6950uz&rid=giphy_s.gif&ct=g'
                    ),
                ),
                fixed_height=FixedHeightImage(
                    webp_size='112580',
                    webp=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/200.webp?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68p'
                        '60zymuq6950uz&rid=200.webp&ct=g'
                    ),
                    mp4_size='36280',
                    mp4=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/200.mp4?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68p6'
                        '0zymuq6950uz&rid=200.mp4&ct=g'
                    ),
                    url=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/200.gif?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68p6'
                        '0zymuq6950uz&rid=200.gif&ct=g'
                    ),
                    height='200',
                    width='298',
                    size='188398',
                ),
                fixed_height_downsampled=FixedHeightDownsampledImage(
                    webp_size='118418',
                    webp=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/200_d.webp?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z6'
                        '8p60zymuq6950uz&rid=200_d.webp&ct=g'
                    ),
                    size='166021',
                    height='200',
                    width='298',
                    url=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/200_d.gif?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68'
                        'p60zymuq6950uz&rid=200_d.gif&ct=g'
                    ),
                ),
                fixed_height_small=FixedHeightSmallImage(
                    webp_size='38138',
                    webp=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/100.webp?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68p'
                        '60zymuq6950uz&rid=100.webp&ct=g'
                    ),
                    mp4_size='12397',
                    mp4=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/100.mp4?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68p6'
                        '0zymuq6950uz&rid=100.mp4&ct=g'
                    ),
                    size='54532',
                    height='100',
                    width='149',
                    url=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/100.gif?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68p6'
                        '0zymuq6950uz&rid=100.gif&ct=g'
                    ),
                ),
                fixed_height_small_still=FixedHeightSmallStillImage(
                    height='100',
                    width='149',
                    url=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/100_s.gif?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68'
                        'p60zymuq6950uz&rid=100_s.gif&ct=g'
                    ),
                ),
                fixed_height_still=FixedHeightStillImage(
                    height='200',
                    width='298',
                    url=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/200_s.gif?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68'
                        'p60zymuq6950uz&rid=200_s.gif&ct=g'
                    ),
                ),
                fixed_width=FixedWidthImage(
                    webp_size='61756',
                    webp=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/200w.webp?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68'
                        'p60zymuq6950uz&rid=200w.webp&ct=g'
                    ),
                    mp4_size='19095',
                    mp4=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/200w.mp4?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68p'
                        '60zymuq6950uz&rid=200w.mp4&ct=g'
                    ),
                    size='87701',
                    height='134',
                    width='200',
                    url=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/200w.gif?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68p'
                        '60zymuq6950uz&rid=200w.gif&ct=g'
                    ),
                ),
                fixed_width_downsampled=FixedWidthDownsampledImage(
                    webp_size='62046',
                    webp=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/200w_d.webp?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z'
                        '68p60zymuq6950uz&rid=200w_d.webp&ct=g'
                    ),
                    size='78853',
                    height='134',
                    width='200',
                    url=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/200w_d.gif?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z6'
                        '8p60zymuq6950uz&rid=200w_d.gif&ct=g'
                    ),
                ),
                fixed_width_small=FixedWidthSmallImage(
                    webp_size='19028',
                    webp=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/100w.webp?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68'
                        'p60zymuq6950uz&rid=100w.webp&ct=g'
                    ),
                    mp4_size='7319',
                    mp4=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/100w.mp4?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68p'
                        '60zymuq6950uz&rid=100w.mp4&ct=g'
                    ),
                    size='25141',
                    height='67',
                    width='100',
                    url=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/100w.gif?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68p'
                        '60zymuq6950uz&rid=100w.gif&ct=g'
                    ),
                ),
                fixed_width_small_still=FixedWidthSmallStillImage(
                    height='67',
                    width='100',
                    url=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/100w_s.gif?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z6'
                        '8p60zymuq6950uz&rid=100w_s.gif&ct=g'
                    ),
                ),
                fixed_width_still=FixedWidthStillImage(
                    height='134',
                    width='200',
                    url=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/200w_s.gif?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z6'
                        '8p60zymuq6950uz&rid=200w_s.gif&ct=g'
                    ),
                ),
                looping=LoopingImage(
                    mp4=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/giphy-loop.mp4?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2'
                        's5z68p60zymuq6950uz&rid=giphy-loop.mp4&ct=g'
                    ),
                ),
                original_still=OriginalStillImage(
                    height='336',
                    width='500',
                    url=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/giphy_s.gif?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z'
                        '68p60zymuq6950uz&rid=giphy_s.gif&ct=g'
                    ),
                ),
                original_mp4=OriginalMp4Image(
                    mp4_size='123856',
                    mp4=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/giphy.mp4?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z68'
                        'p60zymuq6950uz&rid=giphy.mp4&ct=g'
                    ),
                    height='322',
                    width='480',
                ),
                preview=PreviewImage(
                    height='184',
                    width='273',
                    mp4_size='21235',
                    mp4=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/giphy-preview.mp4?cid=9fbc9b3fgy0n3l2a9smslyf34w'
                        'gd2s5z68p60zymuq6950uz&rid=giphy-preview.mp4&ct=g'
                    ),
                ),
                preview_gif=PreviewGifImage(
                    height='90',
                    width='134',
                    url=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/giphy-preview.gif?cid=9fbc9b3fgy0n3l2a9smslyf34w'
                        'gd2s5z68p60zymuq6950uz&rid=giphy-preview.gif&ct=g'
                    ),
                ),
                preview_webp=PreviewWebpImage(
                    size='34118',
                    height='94',
                    width='140',
                    url=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/giphy-preview.webp?cid=9fbc9b3fgy0n3l2a9smslyf34'
                        'wgd2s5z68p60zymuq6950uz&rid=giphy-preview.webp&ct=g'
                    ),
                ),
                still_480w=Still480w(
                    height='323',
                    width='480',
                    url=(
                        'https://media3.giphy.com/media/o6TTJ6ak4A97a/480w_s.jpg?cid=9fbc9b3fgy0n3l2a9smslyf34wgd2s5z6'
                        '8p60zymuq6950uz&rid=480w_s.jpg&ct=g'
                    ),
                    size='430185',
                ),
            ),
            user=User(
                avatar_url='https://media2.giphy.com/avatars/spongebob/U4nimQFVGMqR.jpg',
                banner_image='',
                banner_url='',
                profile_url='https://giphy.com/spongebob/',
                username='spongebob',
                display_name='SpongeBob SquarePants',
                description='Who gifs in a pineapple under the sea?',
                instagram_url='',
                website_url='http://www.spongebob.com',
                is_verified=True,
            ),
            analytics_response_payload=None,
            analytics=None,
        ),
        meta=Meta(
            status=200,
            msg='OK',
            response_id='gy0n3l2a9smslyf34wgd2s5z68p60zymuq6950uz',
        ),
    )

Buy me a coffee

If you find this project useful, consider buying me a coffee!

Buy Me A Coffee

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

giphpy-0.1.2.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

giphpy-0.1.2-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file giphpy-0.1.2.tar.gz.

File metadata

  • Download URL: giphpy-0.1.2.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.9.16 Linux/5.15.0-1031-azure

File hashes

Hashes for giphpy-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3796bfc50c97482f6cc901e256fe6da2038c574ba88ba1cb336e5821950cc016
MD5 dce5ce0a2205bba24d8b7745d2dbcf11
BLAKE2b-256 efbf2e8f134e8acadff34db7217b1e0652e517f5333db9aae4e7f15dcf7c7881

See more details on using hashes here.

File details

Details for the file giphpy-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: giphpy-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.9.16 Linux/5.15.0-1031-azure

File hashes

Hashes for giphpy-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1e62b34a820f36f132af382f66cf6387efa5cb81c1430189609c19e8dda6cb4f
MD5 ca5b102858dc324297e8c731c854ef67
BLAKE2b-256 ad04a2448eddf80f8a3c7163d481b8d5eeaea8a35cfe11997accf9f0b1c96d1f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page