AI APIs for Web Devs - Concrete applications
Tags: ai, webdev, api, machinelearning
Published: 2022-12-19 16:38:24

Have you ever wondered how you, as a web developer, can grasp the power of AI ?

## But first, what’s AI ?

Artificial Intelligence is about allowing a machine to [mimic human behavior](https://www.ibm.com/cloud/learn/what-is-artificial-intelligence). Computers were made to do that by the power of elaborated algorithms. Now, [machine and deep learning](https://www.ibm.com/cloud/learn/machine-learning) make it possible to teach computers with data what we fail to describe in an algorithmic approach. This opens the way for computers to understand and manipulating non structured data :

- 📖 Reading text and understanding concepts like : the topic of the text, the sentiment of the writer and the key concepts it talks about 

-  🗣️ Hearing your voice, understanding the words you say and responding to you (Siri and Alexa : speech to text and text to speech)

-  🎥 Looking at an image or watching a video and understanding the big picture and the details of what it contains

But in order to achieve these objectives, you have to train large models with millions of labeled data.
Now, with [AI as a Service](https://www.geeksforgeeks.org/what-is-artificial-intelligence-as-a-service-aiaas-in-the-tech-industry/), a lot of companies provide off-the-shelf trained models that you can access directly through an API. These companies are either the **tech giants** (Google, Microsoft , Amazon) or other smaller, **more specialized companies**, and there are **hundreds** of them. Some of the most known are : DeepL (translation), OpenAI (text and image analysis), AssemblyAI (speech analysis). [If only there was one global API for accessing all these models… ](https://edenai.co/?referral=webdev-application)


## Usecases :

The very easy access to this intelligence through simple APIs lead to the creation of tons of use cases :

1.  **Automatically parse unstructured documents into a structured form** :
If your app handles scanned documents or pdfs (example: resumes, invoices, ID documents …etc), you can parse them automatically to extract the data it contains and store it into a structured DB for easier manipulation. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m75uq47p7i37jkc6i6v9.png)

```python

import json
import requests

headers = {"Authorization": "Bearer 🔑 Your_API_Key"}

url="https://api.edenai.run/v2/ocr/identity_parser"
data={"providers": "amazon,microsoft,mindee"}
files = {'file': open("🖼️ path/to/your/image.png",'rb')}

response = requests.post(url, data=data, files=files, headers=headers)

result = json.loads(response.text)
print(result['amazon'])
print(result['mindee'])

```


2.  **Reaching out more people by automatically translating your contents** : There are tons of great text translation and language detection apis. Their performance varies depending on the language pair you need.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ghtg38kilr9hyphqno5o.png)

```python

import json
import requests

headers = {"Authorization": "Bearer 🔑 Your_API_Key"}

url ="https://api.edenai.run/v2/translation/automatic_translation"
payload={"providers": "google,deepl", 
         "source_language":"en", 
         "target_language":"fr", 
         "text": "This is a new test."}

response = requests.post(url, json=payload, headers=headers)

result = json.loads(response.text)
print(result['google']['text'])
print(result['deepl']['text'])

```


3.  **Analyze users' feedback and concerns by (semantically) understanding textual content** : text classification, extracting key concepts, and understanding the writer’s sentiment . Natural language analysis can have tons of other applications.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xvcyrigdcyhrhkgwkjws.png)

```python
import json
import requests

headers = {"Authorization": "Bearer 🔑 Your_API_Key"}

url ="https://api.edenai.run/v2/text/sentiment_analysis"
payload={"providers": "emvista,microsoft", 
        'language': "en", 
        'text': "this is a great test"}

response = requests.post(url, json=payload, headers=headers)

result = json.loads(response.text)
print(result['emvista']['items'])
print(result['microsoft']['items'])


```


4.  **Images and videos tagging and classification** : for easier storage and retrieval.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j9mj77vazvyftiu9fdt6.png)

```python

import json
import requests

headers = {"Authorization": "Bearer 🔑 Your_API_Key"}

url = "https://api.edenai.run/v2/image/object_detection"              	 
data={"providers": "clarifai,amazon"}
files = {'file': open("🖼️ path/to/your/image.png",'rb')}

response = requests.post(url, data=data, files=files, headers=headers)
result = json.loads(response.text)
print(result['clarifai']['items'])
print(result['amazon']['items'])

```


5.  **Content moderation** : You can detect explicit content present in an image or a video, detect racist messages or insults in a given text.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iuzf25ruv8cjlv2hl34z.png)

```python
import json
import requests

headers = {"Authorization": "Bearer 🔑 Your_API_Key"}

url=" https://api.edenai.run/v2/image/explicit_content"
data={"providers": "picpurify,microsoft"}
files = {'file': open("🖼️ path/to/your/image.png",'rb')}

response = requests.post(url, data=data, files=files, headers=headers)

result = json.loads(response.text)
print(result['picpurify']['items'])
print(result['microsoft']['items'])

```


6.  **Data anonymization** : You can remove Personally identifiable information (PII) information from a text before making it public. Same thing with an image by blurring faces and license plates for example. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s7s6rcgalv214d5v4ftg.png)

```python

import json
import requests

headers = {"Authorization": "Bearer 🔑 Your_API_Key"}

url ="https://api.edenai.run/v2/text/anonymization"
payload={"providers": "openai", 
         "language": "en", "text": "My name is Jeremy and this is a test"}

response = requests.post(url, json=payload, headers=headers)

result = json.loads(response.text)
print(result['openai']['result'])

```

7.  **Work with audio content** : You can easily transform an audio or a microphone input to a text and analyze it's content. The inverse would be text to speech which gives your app a voice to interact in new ways with your users.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qgrka49qd5nz2u5tritr.png)



## Conclusion : 
As said earlier, there are **tons of companies** producing new APIs each day. You can find a great **variety of performances at different prices**.  So, at [Eden AI](https://edenai.co/?referral=webdev-application), we want to give access to all the power of AI through one standardized API. One interface for you not to bother about how to access intelligence, and only focus on inventing great apps out of it !