Skip to content

Commit

Permalink
BitlyAPI 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Krishna-Singhal committed Aug 17, 2022
1 parent d014b8f commit 62906c2
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 131 deletions.
129 changes: 0 additions & 129 deletions .gitignore

This file was deleted.

17 changes: 17 additions & 0 deletions BitlyAPI/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import requests
from .exceptions import BitlyApiNotWorking, BitlyException

__version__ = "1.0.1"
bitli_api = "https://api.ksprojects.me/bitly?url={}"


def shorten_url(url: str) -> str:
try:
response = requests.get(bitli_api.format(url)).json()
except Exception:
raise BitlyApiNotWorking
if response['success'] is True:
return response.get('link')
if response.get('message'):
raise BitlyException(response['message'])
raise BitlyApiNotWorking
6 changes: 6 additions & 0 deletions BitlyAPI/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class BitlyApiNotWorking(Exception):
pass


class BitlyException(Exception):
pass
61 changes: 59 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,59 @@
# bitly-api-python
A Python wrapper for the bit.ly API
# <b>BitlyAPI</b>

- [<b>Installation</b>](#installation)
- [<b>Documentation</b>](#documentation)
- [<b>Examples</b>](#examples)
- [<b>Short Url</b>](#short-url)
- [<b>Version</b>](#version)
- [<b>Copyright</b>](#copyright)

<br>

# <b>Installation</b>

```shell
pip install bitly-api-python
```

<br>

# <b>Documentation</b>

You can read our Documention on https://api.ksprojects.me/docs

<br>

# <b>Examples</b>

## <b>Short Url</b>

```python
from BitlyAPI import shorten_url

url = "https://github.com/Krishna-Singhal"

shortened_url = shorten_url(url)
print(shortened_url)
```

#### <b>Parameters</b>

Parameter | description
--------- | -----------
`url` | Long url

<br>

## <b>Version</b>

```python
from BitlyAPI import __version__

print(__version__)
```

# <b>Copyright</b>

Copyright (C) 2022 by Krishna-Singhal, < https://github.com/Krishna-Singhal >.

All rights reserved.
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"
30 changes: 30 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import re
import setuptools

with open("BitlyAPI/__init__.py", encoding="utf-8") as f:
version = re.findall(r"__version__ = \"(.+)\"", f.read())[0]

with open("README.md", "r") as fh:
long_description = fh.read()

setuptools.setup(
name="bitly-api-python",
version=version,
author="Krishna-Singhal",
author_email="ylikehits3@gmail.com",
description="Wrapper for [Bitly API](https://api.ksprojects.me/bitly)",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/Krishna-Singhal/bitly-api-python",
project_urls={
"Bug Tracker": "https://github.com/Krishna-Singhal/bitly-api-python/issues",
},
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: OS Independent",
],
install_requires=["requests"],
packages=['BitlyAPI'],
python_requires=">=3.6",
)

0 comments on commit 62906c2

Please sign in to comment.