web API as virtual filesystem?
Asked Answered
C

1

7

I've been toying with the idea of representing RESTful web APIs (e.g. CouchDB, Twitter) as a file system - just for fun and as a learning experience. However, I have no idea whether that's feasible or how to get started.

For example, a resource like http://example.org/foo/bar might be accessible via /mnt/example.org/foo/bar. I imagine ls /mnt/example.org/foo would return bar baz.

While I know of FUSE, I don't really know anything about it. Not being a low-level programmer, I wonder whether there's some sort of Python API, or perhaps I could simply write some Bash script to trigger curl requests for file-system queries?

Any pointers would be greatly appreciated!

Citrange answered 6/8, 2010 at 8:54 Comment(0)
C
6

The standard for this is called WebDAV. See: http://webdav.org

There is even a FUSE driver for it: http://savannah.nongnu.org/projects/davfs2

Looking at the source code it appears that davfs2 is written in C. It could be a fun project re-implementing it in Python or Perl.


Ah, from the comments I see what you want are pointers on how to write a FUSE module. Sure, your idea of writing something like TwitterFS is feasible. It would probably work like the stuff in /proc.

The Perl library for implementing fuse is quite well documented: CPAN - Fuse. All you need is to load the module and implement the relevant callback functions. Looks easy enough.

Here's a Python FUSE library: fusepy. It's not as well documented but there are several examples given including a functional sftp filesystem.

Calva answered 6/8, 2010 at 9:8 Comment(1)
Thanks - I know about WebDAV, but currently can't quite see how it's related (probably due to ignorance) or how I would go about getting started. To clarify: I only control the client, so cannot install any WebDAV modules on the server. Will do more research...Citrange

© 2022 - 2024 — McMap. All rights reserved.