|
75 | 75 |
|
76 | 76 | ## What is [MagicalAPI][website-url]? |
77 | 77 |
|
78 | | -MagicalAPI is your AI edge in **content** and **careers**, Your ultimate tool for **YouTube SEO**, **Resume Parsing**, **LinkedIn data** and more. |
| 78 | +MagicalAPI is your AI edge in **content** and **careers**, Your ultimate tool for **Resume Parsing**, **LinkedIn data** and more. |
79 | 79 |
|
80 | 80 | <br> |
81 | 81 |
|
@@ -149,44 +149,43 @@ client = AsyncClinet() |
149 | 149 |
|
150 | 150 | <br> |
151 | 151 |
|
152 | | -Here is an example of how to get keywords of [Youtube Top Keywords](https://magicalapi.com/services/youtube-keywords) service: |
| 152 | +Here is an example of how to parse a resume using [Resume Parser](https://magicalapi.com/resume/) service: |
153 | 153 |
|
154 | 154 | ```python |
155 | 155 | import asyncio |
| 156 | + |
156 | 157 | from magicalapi.client import AsyncClient |
| 158 | +from magicalapi.errors import APIServerError, APIServerTimedout |
157 | 159 | from magicalapi.types.base import ErrorResponse |
158 | 160 |
|
159 | | -search_sentence = "chatgpt 4 turbo" # your search sentence to get keywords related to |
160 | | -country = "1" # use get_countries method to see countries codes (Default = 1 : WorlWide) |
161 | | -language = "1000" # use get_languages method to see countries codes (Default = 1000 : English) |
| 161 | +resume_url = ( |
| 162 | + "https://resume-resource.com/wp-content/uploads/00123-sales-professional-resume.pdf" |
| 163 | +) |
| 164 | +output_file_name = "resume_parser.json" |
162 | 165 |
|
163 | 166 |
|
164 | 167 | async def main(): |
165 | | - # the api_key will load from the .env file |
166 | | - async with AsyncClient() as client: |
167 | | - # Get YouTube keywords |
168 | | - keywords_response = await client.youtube_top_keywords.get_keywords( |
169 | | - search_sentence=search_sentence, |
170 | | - country=country, |
171 | | - language=language, |
172 | | - ) |
173 | | - if type(keywords_response) == ErrorResponse: |
174 | | - # got error from API |
175 | | - print("Error :", keywords_response.message) |
176 | | - else: |
177 | | - # got response successfully |
178 | | - print("credits :", keywords_response.usage.credits) |
179 | | - print("keywords count :", len(keywords_response.data.keywords)) |
180 | | - |
181 | | - # save response in JSON file |
182 | | - with open("keywords_response.json", "w") as file: |
183 | | - file.write(keywords_response.model_dump_json(indent=3)) |
184 | | - |
185 | | - |
186 | | - # get languages list |
187 | | - # languages = await client.youtube_top_keywords.get_languages() |
188 | | - # get countries list |
189 | | - # countries = await client.youtube_top_keywords.get_countries() |
| 168 | + try: |
| 169 | + # the api_key will load from the .env file |
| 170 | + async with AsyncClient() as client: |
| 171 | + response = await client.resume_parser.get_resume_parser(url=resume_url) |
| 172 | + |
| 173 | + if isinstance(response, ErrorResponse): |
| 174 | + # got error from api |
| 175 | + print("Error :", response.message) |
| 176 | + else: |
| 177 | + # got response successfully |
| 178 | + print("credists :", response.usage.credits) |
| 179 | + # save response in json file |
| 180 | + with open(output_file_name, "w") as file: |
| 181 | + file.write(response.model_dump_json(indent=3)) |
| 182 | + |
| 183 | + print(f"response saved to {output_file_name}") |
| 184 | + except (APIServerError, APIServerTimedout) as e: |
| 185 | + # handling server errors |
| 186 | + print(e) |
| 187 | + except Exception as e: |
| 188 | + print("An error occurred:", str(e)) |
190 | 189 |
|
191 | 190 |
|
192 | 191 | asyncio.run(main()) |
|
0 commit comments