There is an interesting discussion at LtU about difference between DSL and API. I think the difference is less technical and more semantic, in scope and in the role that each of them play.
Considering what they mean the difference is on two levels – domain/application and language/interface. A DSL supports the domain model, which is known to the domain experts. It also tries to hide the implementation details of the source language used for the DSL. A DSL can be high on abstraction and low on transparency, which can boost productivity for work in that domain.
Whereas an API can be developed for multiple reasons – convenience and reusability being two of them. Also, the balance of transparency and abstraction can be different, rather dependent upon purpose of the API. An API can be reusable across more domains and can apply to more scenarios.
In fact a DSL will have its own API. An API can very well be a DSL, if the scope and abstraction is equivalent. What will make it a DSL is the ability to abstract to the domain model from the technical details on both the fronts – data and behavior.
In my opinion the difference is less in the syntax that we end up with. As Stefan Tilkov says, the code can look similar. The difference is in the purpose and it can be important as the evolution of a DSL and an API can be in different directions.
