Is my API design violating RESTful principles?

I'm currently trying to create a RESTful API for a social network. But I'm not sure that my current approach is still consistent with RESTful principles. I would be happy if some brighter heads could give me some advice.

Suppose the following URI represents a user account name field:

people/{UserID}/profile/fields/name

But there are almost a hundred possible fields. Therefore, I want the client to create their own fields or use predefined fields. Suppose the following URI is a predefined field view that includes the name, age, gender fields:

utils/views/field-views/myFieldView

And since field views are higher logic, I don’t want to mix support for field views in the "people / {UserID} / profile / fields" resource. Instead, I want to do the following:

utils/views/field-views/myFieldView/{UserID}


Another example


Suppose we want to perform some quantitative operations (we hope that this is the correct name for it in English). We have the following URIs, while each of them points to a list of people - their friends:

GET people/exampleUID-1/relationships/friends
GET people/exampleUID-2/relationships/friends

And now we want to know which of their friends are also my friends. So we do this:

GET people/myUID/relationships/intersections/{Value-1};{Value-2}

While "{Value-1/2}" are URL-encoded values ​​of "people / exampleUID-1 / friends" and "people / exampleUID-2 / friends". And then we return to the representation of all the people who are friends of all three people.

"RESTful Web Services", RESTful - " ", , RESTful. ?

: "-" REST-RPC ?

,

peta​​p >

+3
3

, ,
RESTful Web Services , , .

:

utils/views/field-views/myFieldView/{UserID}

, RESTful, utils . , (imho) URI API. URI, :

people/{UserID}/profile/fields/name,age,gender/
people/{UserID}/profile/?fields=name,age,gender

fields . , fields URI, - people/{UserID}/profile/. , ?page=1, ?page=2 ..

:
.

-: intersection URI URI. , , friends, , ..

GET people/{UserID}/relationships/friends/intersections/{Value-1};{Value-2}
GET people/{UserID}/relationships/friends/?intersections={Value-1};{Value-2}

, , , people/{UserID}/relationships/friends/

-, :

"{Value-1/2}" - URL "people/exampleUID-1/friends" "/exampleUID-2/"

, {Value-1/2} GET, - , RESTful. friends - , , :

GET friends/{UserID-1};{UserID-2};{UserID-3}

, - ; , , fields. , . OR (,), , AND (;), .

API, .

+2

REST, , GETting '' '/people/{UserId}/profile' '' XML JSON - , . , . , (a) (b) ?

+3

. , . , "RESTful Web Services" ; .: -)

:

. . , . ( ) OR (,) AND (;)? AND, , , . ( . 121 colorpairs)

:

{Value-1/2} URI URI, .:) . , . , , , .

peta​​p >

0

Source: https://habr.com/ru/post/1738801/


All Articles