Assignment-2 | COMP9321 22T1 | WebCMS3
2022/3/21 07(55
Resources / Assignments(/COMP9321/22T1/resources/73
Assignment-2
Copyright By PowCoder代写 加微信 powcoder
Specification Make Submission Check Submissio
REST API for Actor/Actress
In this assignment, you are asked to develop a Flask-Restx da actors/actresses, and allows the consumers to access the dat
The assignment is based on The TV Maze API, which provides using the following links
The source URL: (http://api.worldbank.org/v2/) http://api (http://api.worldbank.org/v2/) Documentations on API C
***Disclaimer: We are using an extremal API provided by TV M real-life web services to add to the learning experience and he inclusion/exclusion of entities and descriptions within the API. such.
In this assignment, you are going to use the information provid
Assignment Specification Question-1: Add a new Actor (3 ma
This operation can be considered as an on-demand ‘import’ o The service will download the JSON data for the given actor/a of the database should be YOURZID.db ) locally after importin
You can use the following to query the API: https://api.tvmaze. For example, you can check the following query: https://api.tv (https://api.tvmaze.com/search/people?q=Brad%20Pitt)
To Add an actor, your API accepts a query parameter called “n name : name of an actor/actress
After importing the collection, the service should return a resp
https://webcms3.cse.unsw.edu.au/COMP9321/22T1/resources/73777
第 1 ⻚页(共 10 ⻚页)
aze nce Thi
Assignment-2 | COMP9321 22T1 | WebCMS3
2022/3/21 07(55
id : a unique integer identifier automatically generated (t last-update : the time the collection is stored in the dat _links : the URL with which the imported collection can
Important : For this assignment , you are asked to access the web pages to be accessed programmatically, some hosts may implementation, download a few test pages and access the co documentation of the tvmaze API to get insights about their rat
POST /actors?name=bard pitt
An example response [This is not what you store in DB, it is th : 201 Created
You must import an actor (e.g, ) if only the give other but they should not match a name like “bard pit”). tolerates typos, capital/small, dashes…etc. and at the s import the matching one (ignoring cases, and any chara than one actor with the same name, you need to add All If there are a few actors with the same exact name, you What and how you store the data in DB is up to you, but need to keep for each Actor. At least you need to store: his/her “shows”. When you are importing an actor, you s “TVmaze” API to see how you can automatically get suc You should never change an ID of a resource (do not up You should replace [HOST_NAME]:[PORT] with correct v A brief description about _links here: https://developer.w (https://developer.wordpress.org/rest-api/using-the-rest
Question 2 – Retrieve an Actor (2 marks)
This operation retrieves an actor by their ID (the ID that is gene actor’s details. Please see the provided response example bel gives the links for previous, next, and current resources if they generated by your application.
“id” : 123,
“last-update”: “2021-04-08-12:34:40”,
“_links”: {
“href”: “http://[HOST_NAME]:[PORT]/act
https://webcms3.cse.unsw.edu.au/COMP9321/22T1/resources/73777
第 2 ⻚页(共 10 ⻚页)
give blo nte e li
n na Be ame cter
an nee tak
“na hou ha
dat alu ord
rate ow t exi
Assignment-2 | COMP9321 22T1 | WebCMS3
2022/3/21 07(55
The interface should look as like below:
GET /actors/{id}
Example Response returns: 200 OK
Question 3- Deleting an Actor (2 marks)
This operation deletes an existing actor from the database. Th
DELETE /actors/{id}
Returns: 200 OK
Question 4 – Update an Actor (2 marks)
“id”: 124,
“last-update”: “2022-03-08-12:34:40”,
“name”: “Some One”,
“country”: “Australia”,
“birthday”: “22-05-1987”,
“deathday”: null,
“shows”: [
“_links”: {
“href”: “http://[HOST_NAME]:[PORT]/act
“previous”: {
“href”: “http://[HOST_NAME]:[PORT]/act
“href”: “http://[HOST_NAME]:[PORT]/act
“message” :”The actor with id 134 was remove
https://webcms3.cse.unsw.edu.au/COMP9321/22T1/resources/73777
第 3 ⻚页(共 10 ⻚页)
ors ors ors
Assignment-2 | COMP9321 22T1 | WebCMS3
2022/3/21 07(55
This operation partially updates the details of a given Actor. The interface should look like the example below:
The above payload is just an example; it can contain any of th know the existing attributes.
Returns: 200 OK
Question 5 – Retrieve the list of available Actor
This operation retrieves all available actors. The interface shou
GET /actors?order=
All four parameters are optional with default values being “ord used for pagination; “size” shows the number of actors per pa the given criteria. The string consists of two parts: the first part and ‘-‘ indicates ordering descendingly. The second part is an last-update}. Here are some sample values of “order” :
PATCH /actors/{id}
“name”: “Some One”,
“country”: “Australia”,
“birthday”: “22-05-1987”,
“deathday”: null,
“id” : 123,
“last-update”: “2021-04-08-12:34:50”,
“_links”: {
“href”: “http://[HOST_NAME]:[PORT]/act
order by “name ascending” and “id ascendi In this case, sorti ng by “name” has p riority ” name ASC, id ASC ”
order by “country descending”
https://webcms3.cse.unsw.edu.au/COMP9321/22T1/resources/73777
第 4 ⻚页(共 10 ⻚页)
Assignment-2 | COMP9321 22T1 | WebCMS3
2022/3/21 07(55
“filter” is also another comma-separated value (id, name, coun should be shown for each actor accordingly. Take a look at the
GET /actors?order=+id&page=1&page_size=10&filter
All four parameters are optional with default values being “ord Returns: 200 OK
Question 6 – get the statistics of the existing A
This operation accepts a parameter called “format” which can should provide the following information: In case when the for image format) and the image illustrates the requested informati visualization such as choosing appropriate visualization type a
Actors break down by an attribute determined by the “b the following Actors’ attributes: “country” (showing the (represents what percentages of actors are alive). You m Total Number of actors
Total Number of actors updated in the last 24 hours The interface should look as below when the format is JSON:
“page”: 1,
“page-size”: 100,
“actors”: [
“name” : ” ”
“name” : ” ”
“_links”: {
“href”: “http://[HOST_NAME]:[PORT]/act
“href”: “http://[HOST_NAME]:[PORT]/act
https://webcms3.cse.unsw.edu.au/COMP9321/22T1/resources/73777
第 5 ⻚页(共 10 ⻚页)
y” p perc ay
Assignment-2 | COMP9321 22T1 | WebCMS3
2022/3/21 07(55
GET /actors/statistics?format=json&by=country,ge
Returns: 200 OK
You can only use the libraries (latest versions) used in th TVMAZE API is only used in Question 1 for importing a local database
There is no template code for this assignment, your sub Your submission will be marked manually.
You should adhere to the best design guidelines for RES JSON format with proper status codes, full API docume operation summary, parameter descriptions, default valu You should consider cases such as invalid titles or any i the data source, return error 404)
You should return appropriate responses (JSON) in case Your code must be implemented in flask-restx and auto Your code must be executable in CSE machines
Your code must not require installing any software (pyth Your code must be written in Python 3.5 or newer versio Your operations (API methods) must return appropriate r 500 Internal Server Error is an inappropriate response! Make sure you are using the right datatypes in the datab Some of the responses of some operations contain “_lin “next”, and “previous” resources.
Submission:
The Deadline is Monday the 4th of April 2022 20:00 One and only one Python script file named ” YOUR_ZID How I can submit my assignment?
Go to the assignment page click on the “Make Submissi sure that the files are not empty, and submit the files tog Can I submit my file after the deadline?
Yes, you can. But 5% of your assignment will be deduct
“total”: 1241,
“total-updated”: 24,
“by-country” : { “Australia”: 60.7, “USA”: 19
“gender” : { “Mail”: 48.6, “Femail”: 51.4}