Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using API for the dictionary script #204

Open
ghost opened this issue May 20, 2024 · 2 comments
Open

Using API for the dictionary script #204

ghost opened this issue May 20, 2024 · 2 comments

Comments

@ghost
Copy link

ghost commented May 20, 2024

I am not sure how that dictionary script is working. But I might offer you a simpler approach. Using an API can be a good idea as it makes the program simple. I don't know the pros and cons of using an Api but if I am wrong, please excuse me and I sincerely apologise and ask you to explain.

@ninja-noodle
Copy link

I think the original dictionary script should be fine as it uses the Python's dictionary module which is sort of similar to an API.

Python's module are packages which are installed locally with the script.

Pros:

  • no internet connection required (although in this case, the dictionary module does need internet because it connects to an external site 'wordnetweb.princeton.edu' to get the words data)
  • it could run faster than API in some cases (where large data are retrieved) since it's running locally in your own computer
  • they are mostly free to use (base on my experiences, python's modules can be use freely)

Cons:

  • manual updating of modules are required (as it is installed locally, you do need to update it by yourself though python IDEs like PyCharm does have an auto-update for python modules)
  • can be hard to keep the code organized and readable (as modules are installed along side with the scripts, the size and complexity of the project can increase)

APIs (Application Programing Interface) are sort of like 'bridges' that connect the user and the API's host server to retrieve data that the user specifies

[[ User's script or program ]]<=======>[[ API ]]<========>[[ Another program or online Server ]]

Imagine, the dictionary script is a customer in a restaurant, APIs are similar to the waiters of the restaurant and the kitchen is the server or another program that is hosted online.

The API takes the info of what the user wants, send it to the server, take the data that the server sends back and deliver it back to the user.

Pros:

  • no need to install anything locally (which reduces the project size and makes it easier to read)
  • it can not only be used for getting data, but also for other purposes (eg. Google Drive API allows the user to upload files to the drive just with code)
  • a vast amount of APIs for a variety of purposes are available (unlike the python modules which can be limited, many kinds of APIs are available (eg. weather api, maps api, etc)
  • no updates are required as the API's host will be the one updating the API, its functionalities and stuffs

Cons:

  • requires internet connection
  • can be a little slower than modules in some cases (but it's not really that noticeable and aren't a problem in most cases)
  • not all are free (there are some APIs that are free to use but most of the 'most-used' or 'important' or 'big' APIs are not free. eg. Google Maps api which has free trial but needs to fill a billing address which is annoying ;-;)

So yeah both have their own pros and cons but I think it's your choice to use the one that's the most suitable for your project.
In this dictionary case, either way requires internet connection so it could be assume the same.

I'm also a novice in programming so if there's any mistakes in my explanation, feel free to correct me : )

But I do hope you can a better glance between API and python modules :D

@ghost
Copy link
Author

ghost commented May 29, 2024

Thanks a lot NINJA NOODLE for answering my doubt. I am just 15 yrs old now, and I just have a little experience in python. Thanks again for such an exhaustive and highly detailed explanation. Have a great day...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant