Skip to main content
add information about the parameters
Source Link
zggame
  • 999
  • 2
  • 9
  • 16

I need to design a REST API to return a resource for a set of parameters. Let us say I need to return a sequence of the numbers, which is determined by three parameters: the generating method, the initial seed, and the scale. The first draft I come up is

(GET/POST) http://url/sequence?method=A&seed=100&scale=5. 

The sequence is generated on the fly but is deterministic given the parameter set (A,100,5), so therefore cacheable. But this feels very unrestful. I can maybe change it into

(GET) http://url/sequence/A/100/5. 

Which one is better? Or neither is good?

Also, scale might be optional with the default value 1. This is easy to handle as query but not so obvious in URL path. How should I handle it?


I should have added some information of my parameter set. There are only a few "method"s, but there are in principal infinite "seed"s and "scale"s.

I need to design a REST API to return a resource for a set of parameters. Let us say I need to return a sequence of the numbers, which is determined by three parameters: the generating method, the initial seed, and the scale. The first draft I come up is

(GET/POST) http://url/sequence?method=A&seed=100&scale=5. 

The sequence is generated on the fly but is deterministic given the parameter set (A,100,5), so therefore cacheable. But this feels very unrestful. I can maybe change it into

(GET) http://url/sequence/A/100/5. 

Which one is better? Or neither is good?

Also, scale might be optional with the default value 1. This is easy to handle as query but not so obvious in URL path. How should I handle it?

I need to design a REST API to return a resource for a set of parameters. Let us say I need to return a sequence of the numbers, which is determined by three parameters: the generating method, the initial seed, and the scale. The first draft I come up is

(GET/POST) http://url/sequence?method=A&seed=100&scale=5. 

The sequence is generated on the fly but is deterministic given the parameter set (A,100,5), so therefore cacheable. But this feels very unrestful. I can maybe change it into

(GET) http://url/sequence/A/100/5. 

Which one is better? Or neither is good?

Also, scale might be optional with the default value 1. This is easy to handle as query but not so obvious in URL path. How should I handle it?


I should have added some information of my parameter set. There are only a few "method"s, but there are in principal infinite "seed"s and "scale"s.

added 3 characters in body
Source Link
user1907906
user1907906

I need to design a REST API to return a resource for a set of parameters. Let us say I need to return a sequence of the numbers, which is determined by three parameters: the generating method, the initial seed, and the scale. The first draft I come up is (GET/POST) http://url/sequence?method=A&seed=100&scale=5. The

(GET/POST) http://url/sequence?method=A&seed=100&scale=5. 

The sequence is generated on-fly the fly but is deterministic given the parameter set (A,100,5)(A,100,5), so therefore cacheable. But this feels very unrestful. I can maybe change it into (GET) http://url/sequence/A/100/5. Which

(GET) http://url/sequence/A/100/5. 

Which one is better? Or neither is good?

Also, "scale"scale might be optional (withwith the default value 1)1. This is easy to handle as query but not so obvious in URL path. How should I handle it?

Thanks in advance.

I need to design a REST API to return a resource for a set of parameters. Let us say I need to return a sequence of the numbers, which is determined by three parameters: the generating method, the initial seed, and the scale. The first draft I come up is (GET/POST) http://url/sequence?method=A&seed=100&scale=5. The sequence is generated on-fly but is deterministic given the parameter set (A,100,5), so therefore cacheable. But this feels very unrestful. I can maybe change it into (GET) http://url/sequence/A/100/5. Which one is better? Or neither is good?

Also, "scale" might be optional (with the default value 1). This is easy to handle as query but not so obvious in URL path. How should I handle it?

Thanks in advance.

I need to design a REST API to return a resource for a set of parameters. Let us say I need to return a sequence of the numbers, which is determined by three parameters: the generating method, the initial seed, and the scale. The first draft I come up is

(GET/POST) http://url/sequence?method=A&seed=100&scale=5. 

The sequence is generated on the fly but is deterministic given the parameter set (A,100,5), so therefore cacheable. But this feels very unrestful. I can maybe change it into

(GET) http://url/sequence/A/100/5. 

Which one is better? Or neither is good?

Also, scale might be optional with the default value 1. This is easy to handle as query but not so obvious in URL path. How should I handle it?

Source Link
zggame
  • 999
  • 2
  • 9
  • 16

How to design a REST API for a set of parameters?

I need to design a REST API to return a resource for a set of parameters. Let us say I need to return a sequence of the numbers, which is determined by three parameters: the generating method, the initial seed, and the scale. The first draft I come up is (GET/POST) http://url/sequence?method=A&seed=100&scale=5. The sequence is generated on-fly but is deterministic given the parameter set (A,100,5), so therefore cacheable. But this feels very unrestful. I can maybe change it into (GET) http://url/sequence/A/100/5. Which one is better? Or neither is good?

Also, "scale" might be optional (with the default value 1). This is easy to handle as query but not so obvious in URL path. How should I handle it?

Thanks in advance.